
obj/user/cat:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 43 01 00 00       	call   800174 <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <cat>:

char buf[8192];

void
cat(int f, char *s)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	57                   	push   %edi
  800038:	56                   	push   %esi
  800039:	53                   	push   %ebx
  80003a:	83 ec 2c             	sub    $0x2c,%esp
  80003d:	8b 75 08             	mov    0x8(%ebp),%esi
  800040:	8b 7d 0c             	mov    0xc(%ebp),%edi
	long n;
	int r;

	while ((n = read(f, buf, (long)sizeof(buf))) > 0)
  800043:	eb 40                	jmp    800085 <cat+0x51>
		if ((r = write(1, buf, n)) != n)
  800045:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800049:	c7 44 24 04 80 60 80 	movl   $0x806080,0x4(%esp)
  800050:	00 
  800051:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  800058:	e8 1d 14 00 00       	call   80147a <write>
  80005d:	39 c3                	cmp    %eax,%ebx
  80005f:	74 24                	je     800085 <cat+0x51>
			panic("write error copying %s: %e", s, r);
  800061:	89 44 24 10          	mov    %eax,0x10(%esp)
  800065:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  800069:	c7 44 24 08 60 2a 80 	movl   $0x802a60,0x8(%esp)
  800070:	00 
  800071:	c7 44 24 04 0d 00 00 	movl   $0xd,0x4(%esp)
  800078:	00 
  800079:	c7 04 24 7b 2a 80 00 	movl   $0x802a7b,(%esp)
  800080:	e8 5b 01 00 00       	call   8001e0 <_panic>
cat(int f, char *s)
{
	long n;
	int r;

	while ((n = read(f, buf, (long)sizeof(buf))) > 0)
  800085:	c7 44 24 08 00 20 00 	movl   $0x2000,0x8(%esp)
  80008c:	00 
  80008d:	c7 44 24 04 80 60 80 	movl   $0x806080,0x4(%esp)
  800094:	00 
  800095:	89 34 24             	mov    %esi,(%esp)
  800098:	e8 66 14 00 00       	call   801503 <read>
  80009d:	89 c3                	mov    %eax,%ebx
  80009f:	85 c0                	test   %eax,%eax
  8000a1:	7f a2                	jg     800045 <cat+0x11>
		if ((r = write(1, buf, n)) != n)
			panic("write error copying %s: %e", s, r);
	if (n < 0)
  8000a3:	85 c0                	test   %eax,%eax
  8000a5:	79 24                	jns    8000cb <cat+0x97>
		panic("error reading %s: %e", s, n);
  8000a7:	89 44 24 10          	mov    %eax,0x10(%esp)
  8000ab:	89 7c 24 0c          	mov    %edi,0xc(%esp)
  8000af:	c7 44 24 08 86 2a 80 	movl   $0x802a86,0x8(%esp)
  8000b6:	00 
  8000b7:	c7 44 24 04 0f 00 00 	movl   $0xf,0x4(%esp)
  8000be:	00 
  8000bf:	c7 04 24 7b 2a 80 00 	movl   $0x802a7b,(%esp)
  8000c6:	e8 15 01 00 00       	call   8001e0 <_panic>
}
  8000cb:	83 c4 2c             	add    $0x2c,%esp
  8000ce:	5b                   	pop    %ebx
  8000cf:	5e                   	pop    %esi
  8000d0:	5f                   	pop    %edi
  8000d1:	5d                   	pop    %ebp
  8000d2:	c3                   	ret    

008000d3 <umain>:

void
umain(int argc, char **argv)
{
  8000d3:	55                   	push   %ebp
  8000d4:	89 e5                	mov    %esp,%ebp
  8000d6:	57                   	push   %edi
  8000d7:	56                   	push   %esi
  8000d8:	53                   	push   %ebx
  8000d9:	83 ec 2c             	sub    $0x2c,%esp
  8000dc:	8b 75 0c             	mov    0xc(%ebp),%esi
	int f, i;

	argv0 = "cat";
  8000df:	c7 05 84 80 80 00 9b 	movl   $0x802a9b,0x808084
  8000e6:	2a 80 00 
	if (argc == 1)
  8000e9:	83 7d 08 01          	cmpl   $0x1,0x8(%ebp)
  8000ed:	74 0d                	je     8000fc <umain+0x29>
		cat(0, "<stdin>");
  8000ef:	bb 01 00 00 00       	mov    $0x1,%ebx
	else
		for (i = 1; i < argc; i++) {
  8000f4:	83 7d 08 01          	cmpl   $0x1,0x8(%ebp)
  8000f8:	7f 18                	jg     800112 <umain+0x3f>
  8000fa:	eb 70                	jmp    80016c <umain+0x99>
{
	int f, i;

	argv0 = "cat";
	if (argc == 1)
		cat(0, "<stdin>");
  8000fc:	c7 44 24 04 9f 2a 80 	movl   $0x802a9f,0x4(%esp)
  800103:	00 
  800104:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80010b:	e8 24 ff ff ff       	call   800034 <cat>
  800110:	eb 5a                	jmp    80016c <umain+0x99>
	if (n < 0)
		panic("error reading %s: %e", s, n);
}

void
umain(int argc, char **argv)
  800112:	89 5d e4             	mov    %ebx,-0x1c(%ebp)
	argv0 = "cat";
	if (argc == 1)
		cat(0, "<stdin>");
	else
		for (i = 1; i < argc; i++) {
			f = open(argv[i], O_RDONLY);
  800115:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  80011c:	00 
  80011d:	8b 04 9e             	mov    (%esi,%ebx,4),%eax
  800120:	89 04 24             	mov    %eax,(%esp)
  800123:	e8 64 19 00 00       	call   801a8c <open>
  800128:	89 c7                	mov    %eax,%edi
			if (f < 0)
  80012a:	85 c0                	test   %eax,%eax
  80012c:	79 1c                	jns    80014a <umain+0x77>
				printf("can't open %s: %e\n", argv[i], f);
  80012e:	89 44 24 08          	mov    %eax,0x8(%esp)
  800132:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800135:	8b 04 96             	mov    (%esi,%edx,4),%eax
  800138:	89 44 24 04          	mov    %eax,0x4(%esp)
  80013c:	c7 04 24 a7 2a 80 00 	movl   $0x802aa7,(%esp)
  800143:	e8 8f 1a 00 00       	call   801bd7 <printf>
  800148:	eb 1a                	jmp    800164 <umain+0x91>
			else {
				cat(f, argv[i]);
  80014a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80014d:	8b 04 96             	mov    (%esi,%edx,4),%eax
  800150:	89 44 24 04          	mov    %eax,0x4(%esp)
  800154:	89 3c 24             	mov    %edi,(%esp)
  800157:	e8 d8 fe ff ff       	call   800034 <cat>
				close(f);
  80015c:	89 3c 24             	mov    %edi,(%esp)
  80015f:	e8 58 15 00 00       	call   8016bc <close>

	argv0 = "cat";
	if (argc == 1)
		cat(0, "<stdin>");
	else
		for (i = 1; i < argc; i++) {
  800164:	83 c3 01             	add    $0x1,%ebx
  800167:	39 5d 08             	cmp    %ebx,0x8(%ebp)
  80016a:	7f a6                	jg     800112 <umain+0x3f>
			else {
				cat(f, argv[i]);
				close(f);
			}
		}
}
  80016c:	83 c4 2c             	add    $0x2c,%esp
  80016f:	5b                   	pop    %ebx
  800170:	5e                   	pop    %esi
  800171:	5f                   	pop    %edi
  800172:	5d                   	pop    %ebp
  800173:	c3                   	ret    

00800174 <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  800174:	55                   	push   %ebp
  800175:	89 e5                	mov    %esp,%ebp
  800177:	83 ec 18             	sub    $0x18,%esp
  80017a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80017d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800180:	8b 75 08             	mov    0x8(%ebp),%esi
  800183:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  800186:	e8 de 0f 00 00       	call   801169 <sys_getenvid>
	env = &envs [ENVX(envid)];
  80018b:	25 ff 03 00 00       	and    $0x3ff,%eax
  800190:	6b c0 7c             	imul   $0x7c,%eax,%eax
  800193:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800198:	a3 80 80 80 00       	mov    %eax,0x808080

	// save the name of the program so that panic() can use it
	if (argc > 0)
  80019d:	85 f6                	test   %esi,%esi
  80019f:	7e 07                	jle    8001a8 <libmain+0x34>
		binaryname = argv[0];
  8001a1:	8b 03                	mov    (%ebx),%eax
  8001a3:	a3 00 60 80 00       	mov    %eax,0x806000

	// call user main routine
	umain(argc, argv);
  8001a8:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8001ac:	89 34 24             	mov    %esi,(%esp)
  8001af:	e8 1f ff ff ff       	call   8000d3 <umain>

	// exit gracefully
	exit();
  8001b4:	e8 0b 00 00 00       	call   8001c4 <exit>
}
  8001b9:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8001bc:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8001bf:	89 ec                	mov    %ebp,%esp
  8001c1:	5d                   	pop    %ebp
  8001c2:	c3                   	ret    
	...

008001c4 <exit>:

#include <inc/lib.h>

void
exit(void)
{
  8001c4:	55                   	push   %ebp
  8001c5:	89 e5                	mov    %esp,%ebp
  8001c7:	83 ec 18             	sub    $0x18,%esp
	close_all();
  8001ca:	e8 6a 15 00 00       	call   801739 <close_all>
	sys_env_destroy(0);
  8001cf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8001d6:	e8 c2 0f 00 00       	call   80119d <sys_env_destroy>
}
  8001db:	c9                   	leave  
  8001dc:	c3                   	ret    
  8001dd:	00 00                	add    %al,(%eax)
	...

008001e0 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  8001e0:	55                   	push   %ebp
  8001e1:	89 e5                	mov    %esp,%ebp
  8001e3:	53                   	push   %ebx
  8001e4:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  8001e7:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  8001ea:	a1 84 80 80 00       	mov    0x808084,%eax
  8001ef:	85 c0                	test   %eax,%eax
  8001f1:	74 10                	je     800203 <_panic+0x23>
		cprintf("%s: ", argv0);
  8001f3:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001f7:	c7 04 24 d1 2a 80 00 	movl   $0x802ad1,(%esp)
  8001fe:	e8 a2 00 00 00       	call   8002a5 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  800203:	8b 45 0c             	mov    0xc(%ebp),%eax
  800206:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80020a:	8b 45 08             	mov    0x8(%ebp),%eax
  80020d:	89 44 24 08          	mov    %eax,0x8(%esp)
  800211:	a1 00 60 80 00       	mov    0x806000,%eax
  800216:	89 44 24 04          	mov    %eax,0x4(%esp)
  80021a:	c7 04 24 d6 2a 80 00 	movl   $0x802ad6,(%esp)
  800221:	e8 7f 00 00 00       	call   8002a5 <cprintf>
	vcprintf(fmt, ap);
  800226:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80022a:	8b 45 10             	mov    0x10(%ebp),%eax
  80022d:	89 04 24             	mov    %eax,(%esp)
  800230:	e8 0f 00 00 00       	call   800244 <vcprintf>
	cprintf("\n");
  800235:	c7 04 24 2e 2f 80 00 	movl   $0x802f2e,(%esp)
  80023c:	e8 64 00 00 00       	call   8002a5 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  800241:	cc                   	int3   
  800242:	eb fd                	jmp    800241 <_panic+0x61>

00800244 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800244:	55                   	push   %ebp
  800245:	89 e5                	mov    %esp,%ebp
  800247:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  80024d:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800254:	00 00 00 
	b.cnt = 0;
  800257:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  80025e:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800261:	8b 45 0c             	mov    0xc(%ebp),%eax
  800264:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800268:	8b 45 08             	mov    0x8(%ebp),%eax
  80026b:	89 44 24 08          	mov    %eax,0x8(%esp)
  80026f:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800275:	89 44 24 04          	mov    %eax,0x4(%esp)
  800279:	c7 04 24 bf 02 80 00 	movl   $0x8002bf,(%esp)
  800280:	e8 d8 01 00 00       	call   80045d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  800285:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  80028b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80028f:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  800295:	89 04 24             	mov    %eax,(%esp)
  800298:	e8 d3 0a 00 00       	call   800d70 <sys_cputs>

	return b.cnt;
}
  80029d:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8002a3:	c9                   	leave  
  8002a4:	c3                   	ret    

008002a5 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  8002a5:	55                   	push   %ebp
  8002a6:	89 e5                	mov    %esp,%ebp
  8002a8:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  8002ab:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  8002ae:	89 44 24 04          	mov    %eax,0x4(%esp)
  8002b2:	8b 45 08             	mov    0x8(%ebp),%eax
  8002b5:	89 04 24             	mov    %eax,(%esp)
  8002b8:	e8 87 ff ff ff       	call   800244 <vcprintf>
	va_end(ap);

	return cnt;
}
  8002bd:	c9                   	leave  
  8002be:	c3                   	ret    

008002bf <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  8002bf:	55                   	push   %ebp
  8002c0:	89 e5                	mov    %esp,%ebp
  8002c2:	53                   	push   %ebx
  8002c3:	83 ec 14             	sub    $0x14,%esp
  8002c6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  8002c9:	8b 03                	mov    (%ebx),%eax
  8002cb:	8b 55 08             	mov    0x8(%ebp),%edx
  8002ce:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  8002d2:	83 c0 01             	add    $0x1,%eax
  8002d5:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  8002d7:	3d ff 00 00 00       	cmp    $0xff,%eax
  8002dc:	75 19                	jne    8002f7 <putch+0x38>
		sys_cputs(b->buf, b->idx);
  8002de:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  8002e5:	00 
  8002e6:	8d 43 08             	lea    0x8(%ebx),%eax
  8002e9:	89 04 24             	mov    %eax,(%esp)
  8002ec:	e8 7f 0a 00 00       	call   800d70 <sys_cputs>
		b->idx = 0;
  8002f1:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  8002f7:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  8002fb:	83 c4 14             	add    $0x14,%esp
  8002fe:	5b                   	pop    %ebx
  8002ff:	5d                   	pop    %ebp
  800300:	c3                   	ret    
	...

00800310 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800310:	55                   	push   %ebp
  800311:	89 e5                	mov    %esp,%ebp
  800313:	57                   	push   %edi
  800314:	56                   	push   %esi
  800315:	53                   	push   %ebx
  800316:	83 ec 4c             	sub    $0x4c,%esp
  800319:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80031c:	89 d6                	mov    %edx,%esi
  80031e:	8b 45 08             	mov    0x8(%ebp),%eax
  800321:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800324:	8b 55 0c             	mov    0xc(%ebp),%edx
  800327:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80032a:	8b 45 10             	mov    0x10(%ebp),%eax
  80032d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800330:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800333:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800336:	b9 00 00 00 00       	mov    $0x0,%ecx
  80033b:	39 d1                	cmp    %edx,%ecx
  80033d:	72 15                	jb     800354 <printnum+0x44>
  80033f:	77 07                	ja     800348 <printnum+0x38>
  800341:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800344:	39 d0                	cmp    %edx,%eax
  800346:	76 0c                	jbe    800354 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800348:	83 eb 01             	sub    $0x1,%ebx
  80034b:	85 db                	test   %ebx,%ebx
  80034d:	8d 76 00             	lea    0x0(%esi),%esi
  800350:	7f 61                	jg     8003b3 <printnum+0xa3>
  800352:	eb 70                	jmp    8003c4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800354:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800358:	83 eb 01             	sub    $0x1,%ebx
  80035b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80035f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800363:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800367:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80036b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80036e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800371:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800374:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800378:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80037f:	00 
  800380:	8b 45 d8             	mov    -0x28(%ebp),%eax
  800383:	89 04 24             	mov    %eax,(%esp)
  800386:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800389:	89 54 24 04          	mov    %edx,0x4(%esp)
  80038d:	e8 4e 24 00 00       	call   8027e0 <__udivdi3>
  800392:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  800395:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  800398:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80039c:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8003a0:	89 04 24             	mov    %eax,(%esp)
  8003a3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8003a7:	89 f2                	mov    %esi,%edx
  8003a9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8003ac:	e8 5f ff ff ff       	call   800310 <printnum>
  8003b1:	eb 11                	jmp    8003c4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  8003b3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003b7:	89 3c 24             	mov    %edi,(%esp)
  8003ba:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8003bd:	83 eb 01             	sub    $0x1,%ebx
  8003c0:	85 db                	test   %ebx,%ebx
  8003c2:	7f ef                	jg     8003b3 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  8003c4:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003c8:	8b 74 24 04          	mov    0x4(%esp),%esi
  8003cc:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8003cf:	89 44 24 08          	mov    %eax,0x8(%esp)
  8003d3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8003da:	00 
  8003db:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8003de:	89 14 24             	mov    %edx,(%esp)
  8003e1:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  8003e4:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  8003e8:	e8 23 25 00 00       	call   802910 <__umoddi3>
  8003ed:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003f1:	0f be 80 f2 2a 80 00 	movsbl 0x802af2(%eax),%eax
  8003f8:	89 04 24             	mov    %eax,(%esp)
  8003fb:	ff 55 e4             	call   *-0x1c(%ebp)
}
  8003fe:	83 c4 4c             	add    $0x4c,%esp
  800401:	5b                   	pop    %ebx
  800402:	5e                   	pop    %esi
  800403:	5f                   	pop    %edi
  800404:	5d                   	pop    %ebp
  800405:	c3                   	ret    

00800406 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800406:	55                   	push   %ebp
  800407:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800409:	83 fa 01             	cmp    $0x1,%edx
  80040c:	7e 0e                	jle    80041c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80040e:	8b 10                	mov    (%eax),%edx
  800410:	8d 4a 08             	lea    0x8(%edx),%ecx
  800413:	89 08                	mov    %ecx,(%eax)
  800415:	8b 02                	mov    (%edx),%eax
  800417:	8b 52 04             	mov    0x4(%edx),%edx
  80041a:	eb 22                	jmp    80043e <getuint+0x38>
	else if (lflag)
  80041c:	85 d2                	test   %edx,%edx
  80041e:	74 10                	je     800430 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800420:	8b 10                	mov    (%eax),%edx
  800422:	8d 4a 04             	lea    0x4(%edx),%ecx
  800425:	89 08                	mov    %ecx,(%eax)
  800427:	8b 02                	mov    (%edx),%eax
  800429:	ba 00 00 00 00       	mov    $0x0,%edx
  80042e:	eb 0e                	jmp    80043e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800430:	8b 10                	mov    (%eax),%edx
  800432:	8d 4a 04             	lea    0x4(%edx),%ecx
  800435:	89 08                	mov    %ecx,(%eax)
  800437:	8b 02                	mov    (%edx),%eax
  800439:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80043e:	5d                   	pop    %ebp
  80043f:	c3                   	ret    

00800440 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800440:	55                   	push   %ebp
  800441:	89 e5                	mov    %esp,%ebp
  800443:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800446:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80044a:	8b 10                	mov    (%eax),%edx
  80044c:	3b 50 04             	cmp    0x4(%eax),%edx
  80044f:	73 0a                	jae    80045b <sprintputch+0x1b>
		*b->buf++ = ch;
  800451:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800454:	88 0a                	mov    %cl,(%edx)
  800456:	83 c2 01             	add    $0x1,%edx
  800459:	89 10                	mov    %edx,(%eax)
}
  80045b:	5d                   	pop    %ebp
  80045c:	c3                   	ret    

0080045d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80045d:	55                   	push   %ebp
  80045e:	89 e5                	mov    %esp,%ebp
  800460:	57                   	push   %edi
  800461:	56                   	push   %esi
  800462:	53                   	push   %ebx
  800463:	83 ec 5c             	sub    $0x5c,%esp
  800466:	8b 7d 08             	mov    0x8(%ebp),%edi
  800469:	8b 75 0c             	mov    0xc(%ebp),%esi
  80046c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80046f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800476:	eb 11                	jmp    800489 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800478:	85 c0                	test   %eax,%eax
  80047a:	0f 84 f9 03 00 00    	je     800879 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  800480:	89 74 24 04          	mov    %esi,0x4(%esp)
  800484:	89 04 24             	mov    %eax,(%esp)
  800487:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  800489:	0f b6 03             	movzbl (%ebx),%eax
  80048c:	83 c3 01             	add    $0x1,%ebx
  80048f:	83 f8 25             	cmp    $0x25,%eax
  800492:	75 e4                	jne    800478 <vprintfmt+0x1b>
  800494:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  800498:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  80049f:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8004a6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8004ad:	b9 00 00 00 00       	mov    $0x0,%ecx
  8004b2:	eb 06                	jmp    8004ba <vprintfmt+0x5d>
  8004b4:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  8004b8:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  8004ba:	0f b6 13             	movzbl (%ebx),%edx
  8004bd:	0f b6 c2             	movzbl %dl,%eax
  8004c0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8004c3:	8d 43 01             	lea    0x1(%ebx),%eax
  8004c6:	83 ea 23             	sub    $0x23,%edx
  8004c9:	80 fa 55             	cmp    $0x55,%dl
  8004cc:	0f 87 8a 03 00 00    	ja     80085c <vprintfmt+0x3ff>
  8004d2:	0f b6 d2             	movzbl %dl,%edx
  8004d5:	ff 24 95 40 2c 80 00 	jmp    *0x802c40(,%edx,4)
  8004dc:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  8004e0:	eb d6                	jmp    8004b8 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  8004e2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8004e5:	83 ea 30             	sub    $0x30,%edx
  8004e8:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  8004eb:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  8004ee:	8d 5a d0             	lea    -0x30(%edx),%ebx
  8004f1:	83 fb 09             	cmp    $0x9,%ebx
  8004f4:	77 54                	ja     80054a <vprintfmt+0xed>
  8004f6:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  8004f9:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  8004fc:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  8004ff:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800502:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800506:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800509:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80050c:	83 fb 09             	cmp    $0x9,%ebx
  80050f:	76 eb                	jbe    8004fc <vprintfmt+0x9f>
  800511:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800514:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800517:	eb 31                	jmp    80054a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800519:	8b 55 14             	mov    0x14(%ebp),%edx
  80051c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80051f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800522:	8b 12                	mov    (%edx),%edx
  800524:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800527:	eb 21                	jmp    80054a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800529:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80052d:	ba 00 00 00 00       	mov    $0x0,%edx
  800532:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800536:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800539:	e9 7a ff ff ff       	jmp    8004b8 <vprintfmt+0x5b>
  80053e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800545:	e9 6e ff ff ff       	jmp    8004b8 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80054a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80054e:	0f 89 64 ff ff ff    	jns    8004b8 <vprintfmt+0x5b>
  800554:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800557:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80055a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80055d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800560:	e9 53 ff ff ff       	jmp    8004b8 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800565:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800568:	e9 4b ff ff ff       	jmp    8004b8 <vprintfmt+0x5b>
  80056d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800570:	8b 45 14             	mov    0x14(%ebp),%eax
  800573:	8d 50 04             	lea    0x4(%eax),%edx
  800576:	89 55 14             	mov    %edx,0x14(%ebp)
  800579:	89 74 24 04          	mov    %esi,0x4(%esp)
  80057d:	8b 00                	mov    (%eax),%eax
  80057f:	89 04 24             	mov    %eax,(%esp)
  800582:	ff d7                	call   *%edi
  800584:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800587:	e9 fd fe ff ff       	jmp    800489 <vprintfmt+0x2c>
  80058c:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  80058f:	8b 45 14             	mov    0x14(%ebp),%eax
  800592:	8d 50 04             	lea    0x4(%eax),%edx
  800595:	89 55 14             	mov    %edx,0x14(%ebp)
  800598:	8b 00                	mov    (%eax),%eax
  80059a:	89 c2                	mov    %eax,%edx
  80059c:	c1 fa 1f             	sar    $0x1f,%edx
  80059f:	31 d0                	xor    %edx,%eax
  8005a1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8005a3:	83 f8 12             	cmp    $0x12,%eax
  8005a6:	7f 0b                	jg     8005b3 <vprintfmt+0x156>
  8005a8:	8b 14 85 a0 2d 80 00 	mov    0x802da0(,%eax,4),%edx
  8005af:	85 d2                	test   %edx,%edx
  8005b1:	75 20                	jne    8005d3 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  8005b3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8005b7:	c7 44 24 08 03 2b 80 	movl   $0x802b03,0x8(%esp)
  8005be:	00 
  8005bf:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005c3:	89 3c 24             	mov    %edi,(%esp)
  8005c6:	e8 36 03 00 00       	call   800901 <printfmt>
  8005cb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8005ce:	e9 b6 fe ff ff       	jmp    800489 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  8005d3:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8005d7:	c7 44 24 08 f2 2e 80 	movl   $0x802ef2,0x8(%esp)
  8005de:	00 
  8005df:	89 74 24 04          	mov    %esi,0x4(%esp)
  8005e3:	89 3c 24             	mov    %edi,(%esp)
  8005e6:	e8 16 03 00 00       	call   800901 <printfmt>
  8005eb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8005ee:	e9 96 fe ff ff       	jmp    800489 <vprintfmt+0x2c>
  8005f3:	89 45 cc             	mov    %eax,-0x34(%ebp)
  8005f6:	89 c3                	mov    %eax,%ebx
  8005f8:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8005fb:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8005fe:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800601:	8b 45 14             	mov    0x14(%ebp),%eax
  800604:	8d 50 04             	lea    0x4(%eax),%edx
  800607:	89 55 14             	mov    %edx,0x14(%ebp)
  80060a:	8b 00                	mov    (%eax),%eax
  80060c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80060f:	85 c0                	test   %eax,%eax
  800611:	b8 0c 2b 80 00       	mov    $0x802b0c,%eax
  800616:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80061a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80061d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800621:	7e 06                	jle    800629 <vprintfmt+0x1cc>
  800623:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800627:	75 13                	jne    80063c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800629:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80062c:	0f be 02             	movsbl (%edx),%eax
  80062f:	85 c0                	test   %eax,%eax
  800631:	0f 85 9b 00 00 00    	jne    8006d2 <vprintfmt+0x275>
  800637:	e9 88 00 00 00       	jmp    8006c4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80063c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800640:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800643:	89 0c 24             	mov    %ecx,(%esp)
  800646:	e8 00 03 00 00       	call   80094b <strnlen>
  80064b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80064e:	29 c2                	sub    %eax,%edx
  800650:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800653:	85 d2                	test   %edx,%edx
  800655:	7e d2                	jle    800629 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800657:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  80065b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  80065e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800661:	89 d3                	mov    %edx,%ebx
  800663:	89 74 24 04          	mov    %esi,0x4(%esp)
  800667:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80066a:	89 04 24             	mov    %eax,(%esp)
  80066d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80066f:	83 eb 01             	sub    $0x1,%ebx
  800672:	85 db                	test   %ebx,%ebx
  800674:	7f ed                	jg     800663 <vprintfmt+0x206>
  800676:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800679:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  800680:	eb a7                	jmp    800629 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  800682:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  800686:	74 1a                	je     8006a2 <vprintfmt+0x245>
  800688:	8d 50 e0             	lea    -0x20(%eax),%edx
  80068b:	83 fa 5e             	cmp    $0x5e,%edx
  80068e:	76 12                	jbe    8006a2 <vprintfmt+0x245>
					putch('?', putdat);
  800690:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800694:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  80069b:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  80069e:	66 90                	xchg   %ax,%ax
  8006a0:	eb 0a                	jmp    8006ac <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8006a2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8006a6:	89 04 24             	mov    %eax,(%esp)
  8006a9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8006ac:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  8006b0:	0f be 03             	movsbl (%ebx),%eax
  8006b3:	85 c0                	test   %eax,%eax
  8006b5:	74 05                	je     8006bc <vprintfmt+0x25f>
  8006b7:	83 c3 01             	add    $0x1,%ebx
  8006ba:	eb 29                	jmp    8006e5 <vprintfmt+0x288>
  8006bc:	89 fe                	mov    %edi,%esi
  8006be:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8006c1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8006c4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8006c8:	7f 2e                	jg     8006f8 <vprintfmt+0x29b>
  8006ca:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8006cd:	e9 b7 fd ff ff       	jmp    800489 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8006d2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8006d5:	83 c2 01             	add    $0x1,%edx
  8006d8:	89 7d e0             	mov    %edi,-0x20(%ebp)
  8006db:	89 f7                	mov    %esi,%edi
  8006dd:	8b 75 d0             	mov    -0x30(%ebp),%esi
  8006e0:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  8006e3:	89 d3                	mov    %edx,%ebx
  8006e5:	85 f6                	test   %esi,%esi
  8006e7:	78 99                	js     800682 <vprintfmt+0x225>
  8006e9:	83 ee 01             	sub    $0x1,%esi
  8006ec:	79 94                	jns    800682 <vprintfmt+0x225>
  8006ee:	89 fe                	mov    %edi,%esi
  8006f0:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8006f3:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  8006f6:	eb cc                	jmp    8006c4 <vprintfmt+0x267>
  8006f8:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  8006fb:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  8006fe:	89 74 24 04          	mov    %esi,0x4(%esp)
  800702:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800709:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80070b:	83 eb 01             	sub    $0x1,%ebx
  80070e:	85 db                	test   %ebx,%ebx
  800710:	7f ec                	jg     8006fe <vprintfmt+0x2a1>
  800712:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800715:	e9 6f fd ff ff       	jmp    800489 <vprintfmt+0x2c>
  80071a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80071d:	83 f9 01             	cmp    $0x1,%ecx
  800720:	7e 16                	jle    800738 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800722:	8b 45 14             	mov    0x14(%ebp),%eax
  800725:	8d 50 08             	lea    0x8(%eax),%edx
  800728:	89 55 14             	mov    %edx,0x14(%ebp)
  80072b:	8b 10                	mov    (%eax),%edx
  80072d:	8b 48 04             	mov    0x4(%eax),%ecx
  800730:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800733:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800736:	eb 32                	jmp    80076a <vprintfmt+0x30d>
	else if (lflag)
  800738:	85 c9                	test   %ecx,%ecx
  80073a:	74 18                	je     800754 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80073c:	8b 45 14             	mov    0x14(%ebp),%eax
  80073f:	8d 50 04             	lea    0x4(%eax),%edx
  800742:	89 55 14             	mov    %edx,0x14(%ebp)
  800745:	8b 00                	mov    (%eax),%eax
  800747:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80074a:	89 c1                	mov    %eax,%ecx
  80074c:	c1 f9 1f             	sar    $0x1f,%ecx
  80074f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800752:	eb 16                	jmp    80076a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800754:	8b 45 14             	mov    0x14(%ebp),%eax
  800757:	8d 50 04             	lea    0x4(%eax),%edx
  80075a:	89 55 14             	mov    %edx,0x14(%ebp)
  80075d:	8b 00                	mov    (%eax),%eax
  80075f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800762:	89 c2                	mov    %eax,%edx
  800764:	c1 fa 1f             	sar    $0x1f,%edx
  800767:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80076a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80076d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800770:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800775:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800779:	0f 89 9b 00 00 00    	jns    80081a <vprintfmt+0x3bd>
				putch('-', putdat);
  80077f:	89 74 24 04          	mov    %esi,0x4(%esp)
  800783:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  80078a:	ff d7                	call   *%edi
				num = -(long long) num;
  80078c:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80078f:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800792:	f7 d9                	neg    %ecx
  800794:	83 d3 00             	adc    $0x0,%ebx
  800797:	f7 db                	neg    %ebx
  800799:	b8 0a 00 00 00       	mov    $0xa,%eax
  80079e:	eb 7a                	jmp    80081a <vprintfmt+0x3bd>
  8007a0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8007a3:	89 ca                	mov    %ecx,%edx
  8007a5:	8d 45 14             	lea    0x14(%ebp),%eax
  8007a8:	e8 59 fc ff ff       	call   800406 <getuint>
  8007ad:	89 c1                	mov    %eax,%ecx
  8007af:	89 d3                	mov    %edx,%ebx
  8007b1:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  8007b6:	eb 62                	jmp    80081a <vprintfmt+0x3bd>
  8007b8:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  8007bb:	89 ca                	mov    %ecx,%edx
  8007bd:	8d 45 14             	lea    0x14(%ebp),%eax
  8007c0:	e8 41 fc ff ff       	call   800406 <getuint>
  8007c5:	89 c1                	mov    %eax,%ecx
  8007c7:	89 d3                	mov    %edx,%ebx
  8007c9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  8007ce:	eb 4a                	jmp    80081a <vprintfmt+0x3bd>
  8007d0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  8007d3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007d7:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  8007de:	ff d7                	call   *%edi
			putch('x', putdat);
  8007e0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8007e4:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  8007eb:	ff d7                	call   *%edi
			num = (unsigned long long)
  8007ed:	8b 45 14             	mov    0x14(%ebp),%eax
  8007f0:	8d 50 04             	lea    0x4(%eax),%edx
  8007f3:	89 55 14             	mov    %edx,0x14(%ebp)
  8007f6:	8b 08                	mov    (%eax),%ecx
  8007f8:	bb 00 00 00 00       	mov    $0x0,%ebx
  8007fd:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800802:	eb 16                	jmp    80081a <vprintfmt+0x3bd>
  800804:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800807:	89 ca                	mov    %ecx,%edx
  800809:	8d 45 14             	lea    0x14(%ebp),%eax
  80080c:	e8 f5 fb ff ff       	call   800406 <getuint>
  800811:	89 c1                	mov    %eax,%ecx
  800813:	89 d3                	mov    %edx,%ebx
  800815:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80081a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80081e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800822:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800825:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800829:	89 44 24 08          	mov    %eax,0x8(%esp)
  80082d:	89 0c 24             	mov    %ecx,(%esp)
  800830:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800834:	89 f2                	mov    %esi,%edx
  800836:	89 f8                	mov    %edi,%eax
  800838:	e8 d3 fa ff ff       	call   800310 <printnum>
  80083d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800840:	e9 44 fc ff ff       	jmp    800489 <vprintfmt+0x2c>
  800845:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800848:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80084b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80084f:	89 14 24             	mov    %edx,(%esp)
  800852:	ff d7                	call   *%edi
  800854:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800857:	e9 2d fc ff ff       	jmp    800489 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  80085c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800860:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800867:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800869:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80086c:	80 38 25             	cmpb   $0x25,(%eax)
  80086f:	0f 84 14 fc ff ff    	je     800489 <vprintfmt+0x2c>
  800875:	89 c3                	mov    %eax,%ebx
  800877:	eb f0                	jmp    800869 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800879:	83 c4 5c             	add    $0x5c,%esp
  80087c:	5b                   	pop    %ebx
  80087d:	5e                   	pop    %esi
  80087e:	5f                   	pop    %edi
  80087f:	5d                   	pop    %ebp
  800880:	c3                   	ret    

00800881 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  800881:	55                   	push   %ebp
  800882:	89 e5                	mov    %esp,%ebp
  800884:	83 ec 28             	sub    $0x28,%esp
  800887:	8b 45 08             	mov    0x8(%ebp),%eax
  80088a:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  80088d:	85 c0                	test   %eax,%eax
  80088f:	74 04                	je     800895 <vsnprintf+0x14>
  800891:	85 d2                	test   %edx,%edx
  800893:	7f 07                	jg     80089c <vsnprintf+0x1b>
  800895:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  80089a:	eb 3b                	jmp    8008d7 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  80089c:	89 45 ec             	mov    %eax,-0x14(%ebp)
  80089f:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8008a3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8008a6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8008ad:	8b 45 14             	mov    0x14(%ebp),%eax
  8008b0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8008b4:	8b 45 10             	mov    0x10(%ebp),%eax
  8008b7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8008bb:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8008be:	89 44 24 04          	mov    %eax,0x4(%esp)
  8008c2:	c7 04 24 40 04 80 00 	movl   $0x800440,(%esp)
  8008c9:	e8 8f fb ff ff       	call   80045d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8008ce:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8008d1:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  8008d4:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  8008d7:	c9                   	leave  
  8008d8:	c3                   	ret    

008008d9 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  8008d9:	55                   	push   %ebp
  8008da:	89 e5                	mov    %esp,%ebp
  8008dc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  8008df:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  8008e2:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8008e6:	8b 45 10             	mov    0x10(%ebp),%eax
  8008e9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8008ed:	8b 45 0c             	mov    0xc(%ebp),%eax
  8008f0:	89 44 24 04          	mov    %eax,0x4(%esp)
  8008f4:	8b 45 08             	mov    0x8(%ebp),%eax
  8008f7:	89 04 24             	mov    %eax,(%esp)
  8008fa:	e8 82 ff ff ff       	call   800881 <vsnprintf>
	va_end(ap);

	return rc;
}
  8008ff:	c9                   	leave  
  800900:	c3                   	ret    

00800901 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800901:	55                   	push   %ebp
  800902:	89 e5                	mov    %esp,%ebp
  800904:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800907:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  80090a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80090e:	8b 45 10             	mov    0x10(%ebp),%eax
  800911:	89 44 24 08          	mov    %eax,0x8(%esp)
  800915:	8b 45 0c             	mov    0xc(%ebp),%eax
  800918:	89 44 24 04          	mov    %eax,0x4(%esp)
  80091c:	8b 45 08             	mov    0x8(%ebp),%eax
  80091f:	89 04 24             	mov    %eax,(%esp)
  800922:	e8 36 fb ff ff       	call   80045d <vprintfmt>
	va_end(ap);
}
  800927:	c9                   	leave  
  800928:	c3                   	ret    
  800929:	00 00                	add    %al,(%eax)
  80092b:	00 00                	add    %al,(%eax)
  80092d:	00 00                	add    %al,(%eax)
	...

00800930 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800930:	55                   	push   %ebp
  800931:	89 e5                	mov    %esp,%ebp
  800933:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800936:	b8 00 00 00 00       	mov    $0x0,%eax
  80093b:	80 3a 00             	cmpb   $0x0,(%edx)
  80093e:	74 09                	je     800949 <strlen+0x19>
		n++;
  800940:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800943:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800947:	75 f7                	jne    800940 <strlen+0x10>
		n++;
	return n;
}
  800949:	5d                   	pop    %ebp
  80094a:	c3                   	ret    

0080094b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80094b:	55                   	push   %ebp
  80094c:	89 e5                	mov    %esp,%ebp
  80094e:	53                   	push   %ebx
  80094f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800952:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800955:	85 c9                	test   %ecx,%ecx
  800957:	74 19                	je     800972 <strnlen+0x27>
  800959:	80 3b 00             	cmpb   $0x0,(%ebx)
  80095c:	74 14                	je     800972 <strnlen+0x27>
  80095e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800963:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800966:	39 c8                	cmp    %ecx,%eax
  800968:	74 0d                	je     800977 <strnlen+0x2c>
  80096a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  80096e:	75 f3                	jne    800963 <strnlen+0x18>
  800970:	eb 05                	jmp    800977 <strnlen+0x2c>
  800972:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800977:	5b                   	pop    %ebx
  800978:	5d                   	pop    %ebp
  800979:	c3                   	ret    

0080097a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  80097a:	55                   	push   %ebp
  80097b:	89 e5                	mov    %esp,%ebp
  80097d:	53                   	push   %ebx
  80097e:	8b 45 08             	mov    0x8(%ebp),%eax
  800981:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800984:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  800989:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  80098d:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  800990:	83 c2 01             	add    $0x1,%edx
  800993:	84 c9                	test   %cl,%cl
  800995:	75 f2                	jne    800989 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  800997:	5b                   	pop    %ebx
  800998:	5d                   	pop    %ebp
  800999:	c3                   	ret    

0080099a <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  80099a:	55                   	push   %ebp
  80099b:	89 e5                	mov    %esp,%ebp
  80099d:	56                   	push   %esi
  80099e:	53                   	push   %ebx
  80099f:	8b 45 08             	mov    0x8(%ebp),%eax
  8009a2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009a5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8009a8:	85 f6                	test   %esi,%esi
  8009aa:	74 18                	je     8009c4 <strncpy+0x2a>
  8009ac:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  8009b1:	0f b6 1a             	movzbl (%edx),%ebx
  8009b4:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  8009b7:	80 3a 01             	cmpb   $0x1,(%edx)
  8009ba:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8009bd:	83 c1 01             	add    $0x1,%ecx
  8009c0:	39 ce                	cmp    %ecx,%esi
  8009c2:	77 ed                	ja     8009b1 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  8009c4:	5b                   	pop    %ebx
  8009c5:	5e                   	pop    %esi
  8009c6:	5d                   	pop    %ebp
  8009c7:	c3                   	ret    

008009c8 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  8009c8:	55                   	push   %ebp
  8009c9:	89 e5                	mov    %esp,%ebp
  8009cb:	56                   	push   %esi
  8009cc:	53                   	push   %ebx
  8009cd:	8b 75 08             	mov    0x8(%ebp),%esi
  8009d0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8009d3:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  8009d6:	89 f0                	mov    %esi,%eax
  8009d8:	85 c9                	test   %ecx,%ecx
  8009da:	74 27                	je     800a03 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  8009dc:	83 e9 01             	sub    $0x1,%ecx
  8009df:	74 1d                	je     8009fe <strlcpy+0x36>
  8009e1:	0f b6 1a             	movzbl (%edx),%ebx
  8009e4:	84 db                	test   %bl,%bl
  8009e6:	74 16                	je     8009fe <strlcpy+0x36>
			*dst++ = *src++;
  8009e8:	88 18                	mov    %bl,(%eax)
  8009ea:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  8009ed:	83 e9 01             	sub    $0x1,%ecx
  8009f0:	74 0e                	je     800a00 <strlcpy+0x38>
			*dst++ = *src++;
  8009f2:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  8009f5:	0f b6 1a             	movzbl (%edx),%ebx
  8009f8:	84 db                	test   %bl,%bl
  8009fa:	75 ec                	jne    8009e8 <strlcpy+0x20>
  8009fc:	eb 02                	jmp    800a00 <strlcpy+0x38>
  8009fe:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800a00:	c6 00 00             	movb   $0x0,(%eax)
  800a03:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800a05:	5b                   	pop    %ebx
  800a06:	5e                   	pop    %esi
  800a07:	5d                   	pop    %ebp
  800a08:	c3                   	ret    

00800a09 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800a09:	55                   	push   %ebp
  800a0a:	89 e5                	mov    %esp,%ebp
  800a0c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800a0f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800a12:	0f b6 01             	movzbl (%ecx),%eax
  800a15:	84 c0                	test   %al,%al
  800a17:	74 15                	je     800a2e <strcmp+0x25>
  800a19:	3a 02                	cmp    (%edx),%al
  800a1b:	75 11                	jne    800a2e <strcmp+0x25>
		p++, q++;
  800a1d:	83 c1 01             	add    $0x1,%ecx
  800a20:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800a23:	0f b6 01             	movzbl (%ecx),%eax
  800a26:	84 c0                	test   %al,%al
  800a28:	74 04                	je     800a2e <strcmp+0x25>
  800a2a:	3a 02                	cmp    (%edx),%al
  800a2c:	74 ef                	je     800a1d <strcmp+0x14>
  800a2e:	0f b6 c0             	movzbl %al,%eax
  800a31:	0f b6 12             	movzbl (%edx),%edx
  800a34:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800a36:	5d                   	pop    %ebp
  800a37:	c3                   	ret    

00800a38 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800a38:	55                   	push   %ebp
  800a39:	89 e5                	mov    %esp,%ebp
  800a3b:	53                   	push   %ebx
  800a3c:	8b 55 08             	mov    0x8(%ebp),%edx
  800a3f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800a42:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800a45:	85 c0                	test   %eax,%eax
  800a47:	74 23                	je     800a6c <strncmp+0x34>
  800a49:	0f b6 1a             	movzbl (%edx),%ebx
  800a4c:	84 db                	test   %bl,%bl
  800a4e:	74 24                	je     800a74 <strncmp+0x3c>
  800a50:	3a 19                	cmp    (%ecx),%bl
  800a52:	75 20                	jne    800a74 <strncmp+0x3c>
  800a54:	83 e8 01             	sub    $0x1,%eax
  800a57:	74 13                	je     800a6c <strncmp+0x34>
		n--, p++, q++;
  800a59:	83 c2 01             	add    $0x1,%edx
  800a5c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  800a5f:	0f b6 1a             	movzbl (%edx),%ebx
  800a62:	84 db                	test   %bl,%bl
  800a64:	74 0e                	je     800a74 <strncmp+0x3c>
  800a66:	3a 19                	cmp    (%ecx),%bl
  800a68:	74 ea                	je     800a54 <strncmp+0x1c>
  800a6a:	eb 08                	jmp    800a74 <strncmp+0x3c>
  800a6c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800a71:	5b                   	pop    %ebx
  800a72:	5d                   	pop    %ebp
  800a73:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800a74:	0f b6 02             	movzbl (%edx),%eax
  800a77:	0f b6 11             	movzbl (%ecx),%edx
  800a7a:	29 d0                	sub    %edx,%eax
  800a7c:	eb f3                	jmp    800a71 <strncmp+0x39>

00800a7e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  800a7e:	55                   	push   %ebp
  800a7f:	89 e5                	mov    %esp,%ebp
  800a81:	8b 45 08             	mov    0x8(%ebp),%eax
  800a84:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800a88:	0f b6 10             	movzbl (%eax),%edx
  800a8b:	84 d2                	test   %dl,%dl
  800a8d:	74 15                	je     800aa4 <strchr+0x26>
		if (*s == c)
  800a8f:	38 ca                	cmp    %cl,%dl
  800a91:	75 07                	jne    800a9a <strchr+0x1c>
  800a93:	eb 14                	jmp    800aa9 <strchr+0x2b>
  800a95:	38 ca                	cmp    %cl,%dl
  800a97:	90                   	nop
  800a98:	74 0f                	je     800aa9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  800a9a:	83 c0 01             	add    $0x1,%eax
  800a9d:	0f b6 10             	movzbl (%eax),%edx
  800aa0:	84 d2                	test   %dl,%dl
  800aa2:	75 f1                	jne    800a95 <strchr+0x17>
  800aa4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  800aa9:	5d                   	pop    %ebp
  800aaa:	c3                   	ret    

00800aab <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  800aab:	55                   	push   %ebp
  800aac:	89 e5                	mov    %esp,%ebp
  800aae:	8b 45 08             	mov    0x8(%ebp),%eax
  800ab1:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  800ab5:	0f b6 10             	movzbl (%eax),%edx
  800ab8:	84 d2                	test   %dl,%dl
  800aba:	74 18                	je     800ad4 <strfind+0x29>
		if (*s == c)
  800abc:	38 ca                	cmp    %cl,%dl
  800abe:	75 0a                	jne    800aca <strfind+0x1f>
  800ac0:	eb 12                	jmp    800ad4 <strfind+0x29>
  800ac2:	38 ca                	cmp    %cl,%dl
  800ac4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  800ac8:	74 0a                	je     800ad4 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  800aca:	83 c0 01             	add    $0x1,%eax
  800acd:	0f b6 10             	movzbl (%eax),%edx
  800ad0:	84 d2                	test   %dl,%dl
  800ad2:	75 ee                	jne    800ac2 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  800ad4:	5d                   	pop    %ebp
  800ad5:	c3                   	ret    

00800ad6 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  800ad6:	55                   	push   %ebp
  800ad7:	89 e5                	mov    %esp,%ebp
  800ad9:	83 ec 0c             	sub    $0xc,%esp
  800adc:	89 1c 24             	mov    %ebx,(%esp)
  800adf:	89 74 24 04          	mov    %esi,0x4(%esp)
  800ae3:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800ae7:	8b 7d 08             	mov    0x8(%ebp),%edi
  800aea:	8b 45 0c             	mov    0xc(%ebp),%eax
  800aed:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800af0:	85 c9                	test   %ecx,%ecx
  800af2:	74 30                	je     800b24 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800af4:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800afa:	75 25                	jne    800b21 <memset+0x4b>
  800afc:	f6 c1 03             	test   $0x3,%cl
  800aff:	75 20                	jne    800b21 <memset+0x4b>
		c &= 0xFF;
  800b01:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800b04:	89 d3                	mov    %edx,%ebx
  800b06:	c1 e3 08             	shl    $0x8,%ebx
  800b09:	89 d6                	mov    %edx,%esi
  800b0b:	c1 e6 18             	shl    $0x18,%esi
  800b0e:	89 d0                	mov    %edx,%eax
  800b10:	c1 e0 10             	shl    $0x10,%eax
  800b13:	09 f0                	or     %esi,%eax
  800b15:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800b17:	09 d8                	or     %ebx,%eax
  800b19:	c1 e9 02             	shr    $0x2,%ecx
  800b1c:	fc                   	cld    
  800b1d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800b1f:	eb 03                	jmp    800b24 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800b21:	fc                   	cld    
  800b22:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800b24:	89 f8                	mov    %edi,%eax
  800b26:	8b 1c 24             	mov    (%esp),%ebx
  800b29:	8b 74 24 04          	mov    0x4(%esp),%esi
  800b2d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800b31:	89 ec                	mov    %ebp,%esp
  800b33:	5d                   	pop    %ebp
  800b34:	c3                   	ret    

00800b35 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800b35:	55                   	push   %ebp
  800b36:	89 e5                	mov    %esp,%ebp
  800b38:	83 ec 08             	sub    $0x8,%esp
  800b3b:	89 34 24             	mov    %esi,(%esp)
  800b3e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800b42:	8b 45 08             	mov    0x8(%ebp),%eax
  800b45:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800b48:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800b4b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800b4d:	39 c6                	cmp    %eax,%esi
  800b4f:	73 35                	jae    800b86 <memmove+0x51>
  800b51:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800b54:	39 d0                	cmp    %edx,%eax
  800b56:	73 2e                	jae    800b86 <memmove+0x51>
		s += n;
		d += n;
  800b58:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b5a:	f6 c2 03             	test   $0x3,%dl
  800b5d:	75 1b                	jne    800b7a <memmove+0x45>
  800b5f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b65:	75 13                	jne    800b7a <memmove+0x45>
  800b67:	f6 c1 03             	test   $0x3,%cl
  800b6a:	75 0e                	jne    800b7a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800b6c:	83 ef 04             	sub    $0x4,%edi
  800b6f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800b72:	c1 e9 02             	shr    $0x2,%ecx
  800b75:	fd                   	std    
  800b76:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b78:	eb 09                	jmp    800b83 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800b7a:	83 ef 01             	sub    $0x1,%edi
  800b7d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800b80:	fd                   	std    
  800b81:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800b83:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800b84:	eb 20                	jmp    800ba6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800b86:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800b8c:	75 15                	jne    800ba3 <memmove+0x6e>
  800b8e:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800b94:	75 0d                	jne    800ba3 <memmove+0x6e>
  800b96:	f6 c1 03             	test   $0x3,%cl
  800b99:	75 08                	jne    800ba3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800b9b:	c1 e9 02             	shr    $0x2,%ecx
  800b9e:	fc                   	cld    
  800b9f:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800ba1:	eb 03                	jmp    800ba6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800ba3:	fc                   	cld    
  800ba4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800ba6:	8b 34 24             	mov    (%esp),%esi
  800ba9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800bad:	89 ec                	mov    %ebp,%esp
  800baf:	5d                   	pop    %ebp
  800bb0:	c3                   	ret    

00800bb1 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800bb1:	55                   	push   %ebp
  800bb2:	89 e5                	mov    %esp,%ebp
  800bb4:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800bb7:	8b 45 10             	mov    0x10(%ebp),%eax
  800bba:	89 44 24 08          	mov    %eax,0x8(%esp)
  800bbe:	8b 45 0c             	mov    0xc(%ebp),%eax
  800bc1:	89 44 24 04          	mov    %eax,0x4(%esp)
  800bc5:	8b 45 08             	mov    0x8(%ebp),%eax
  800bc8:	89 04 24             	mov    %eax,(%esp)
  800bcb:	e8 65 ff ff ff       	call   800b35 <memmove>
}
  800bd0:	c9                   	leave  
  800bd1:	c3                   	ret    

00800bd2 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800bd2:	55                   	push   %ebp
  800bd3:	89 e5                	mov    %esp,%ebp
  800bd5:	57                   	push   %edi
  800bd6:	56                   	push   %esi
  800bd7:	53                   	push   %ebx
  800bd8:	8b 75 08             	mov    0x8(%ebp),%esi
  800bdb:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800bde:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800be1:	85 c9                	test   %ecx,%ecx
  800be3:	74 36                	je     800c1b <memcmp+0x49>
		if (*s1 != *s2)
  800be5:	0f b6 06             	movzbl (%esi),%eax
  800be8:	0f b6 1f             	movzbl (%edi),%ebx
  800beb:	38 d8                	cmp    %bl,%al
  800bed:	74 20                	je     800c0f <memcmp+0x3d>
  800bef:	eb 14                	jmp    800c05 <memcmp+0x33>
  800bf1:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800bf6:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800bfb:	83 c2 01             	add    $0x1,%edx
  800bfe:	83 e9 01             	sub    $0x1,%ecx
  800c01:	38 d8                	cmp    %bl,%al
  800c03:	74 12                	je     800c17 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800c05:	0f b6 c0             	movzbl %al,%eax
  800c08:	0f b6 db             	movzbl %bl,%ebx
  800c0b:	29 d8                	sub    %ebx,%eax
  800c0d:	eb 11                	jmp    800c20 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800c0f:	83 e9 01             	sub    $0x1,%ecx
  800c12:	ba 00 00 00 00       	mov    $0x0,%edx
  800c17:	85 c9                	test   %ecx,%ecx
  800c19:	75 d6                	jne    800bf1 <memcmp+0x1f>
  800c1b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800c20:	5b                   	pop    %ebx
  800c21:	5e                   	pop    %esi
  800c22:	5f                   	pop    %edi
  800c23:	5d                   	pop    %ebp
  800c24:	c3                   	ret    

00800c25 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800c25:	55                   	push   %ebp
  800c26:	89 e5                	mov    %esp,%ebp
  800c28:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800c2b:	89 c2                	mov    %eax,%edx
  800c2d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800c30:	39 d0                	cmp    %edx,%eax
  800c32:	73 15                	jae    800c49 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800c34:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800c38:	38 08                	cmp    %cl,(%eax)
  800c3a:	75 06                	jne    800c42 <memfind+0x1d>
  800c3c:	eb 0b                	jmp    800c49 <memfind+0x24>
  800c3e:	38 08                	cmp    %cl,(%eax)
  800c40:	74 07                	je     800c49 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800c42:	83 c0 01             	add    $0x1,%eax
  800c45:	39 c2                	cmp    %eax,%edx
  800c47:	77 f5                	ja     800c3e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800c49:	5d                   	pop    %ebp
  800c4a:	c3                   	ret    

00800c4b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800c4b:	55                   	push   %ebp
  800c4c:	89 e5                	mov    %esp,%ebp
  800c4e:	57                   	push   %edi
  800c4f:	56                   	push   %esi
  800c50:	53                   	push   %ebx
  800c51:	83 ec 04             	sub    $0x4,%esp
  800c54:	8b 55 08             	mov    0x8(%ebp),%edx
  800c57:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800c5a:	0f b6 02             	movzbl (%edx),%eax
  800c5d:	3c 20                	cmp    $0x20,%al
  800c5f:	74 04                	je     800c65 <strtol+0x1a>
  800c61:	3c 09                	cmp    $0x9,%al
  800c63:	75 0e                	jne    800c73 <strtol+0x28>
		s++;
  800c65:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800c68:	0f b6 02             	movzbl (%edx),%eax
  800c6b:	3c 20                	cmp    $0x20,%al
  800c6d:	74 f6                	je     800c65 <strtol+0x1a>
  800c6f:	3c 09                	cmp    $0x9,%al
  800c71:	74 f2                	je     800c65 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800c73:	3c 2b                	cmp    $0x2b,%al
  800c75:	75 0c                	jne    800c83 <strtol+0x38>
		s++;
  800c77:	83 c2 01             	add    $0x1,%edx
  800c7a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800c81:	eb 15                	jmp    800c98 <strtol+0x4d>
	else if (*s == '-')
  800c83:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800c8a:	3c 2d                	cmp    $0x2d,%al
  800c8c:	75 0a                	jne    800c98 <strtol+0x4d>
		s++, neg = 1;
  800c8e:	83 c2 01             	add    $0x1,%edx
  800c91:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800c98:	85 db                	test   %ebx,%ebx
  800c9a:	0f 94 c0             	sete   %al
  800c9d:	74 05                	je     800ca4 <strtol+0x59>
  800c9f:	83 fb 10             	cmp    $0x10,%ebx
  800ca2:	75 18                	jne    800cbc <strtol+0x71>
  800ca4:	80 3a 30             	cmpb   $0x30,(%edx)
  800ca7:	75 13                	jne    800cbc <strtol+0x71>
  800ca9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800cad:	8d 76 00             	lea    0x0(%esi),%esi
  800cb0:	75 0a                	jne    800cbc <strtol+0x71>
		s += 2, base = 16;
  800cb2:	83 c2 02             	add    $0x2,%edx
  800cb5:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800cba:	eb 15                	jmp    800cd1 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800cbc:	84 c0                	test   %al,%al
  800cbe:	66 90                	xchg   %ax,%ax
  800cc0:	74 0f                	je     800cd1 <strtol+0x86>
  800cc2:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800cc7:	80 3a 30             	cmpb   $0x30,(%edx)
  800cca:	75 05                	jne    800cd1 <strtol+0x86>
		s++, base = 8;
  800ccc:	83 c2 01             	add    $0x1,%edx
  800ccf:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800cd1:	b8 00 00 00 00       	mov    $0x0,%eax
  800cd6:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800cd8:	0f b6 0a             	movzbl (%edx),%ecx
  800cdb:	89 cf                	mov    %ecx,%edi
  800cdd:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800ce0:	80 fb 09             	cmp    $0x9,%bl
  800ce3:	77 08                	ja     800ced <strtol+0xa2>
			dig = *s - '0';
  800ce5:	0f be c9             	movsbl %cl,%ecx
  800ce8:	83 e9 30             	sub    $0x30,%ecx
  800ceb:	eb 1e                	jmp    800d0b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800ced:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800cf0:	80 fb 19             	cmp    $0x19,%bl
  800cf3:	77 08                	ja     800cfd <strtol+0xb2>
			dig = *s - 'a' + 10;
  800cf5:	0f be c9             	movsbl %cl,%ecx
  800cf8:	83 e9 57             	sub    $0x57,%ecx
  800cfb:	eb 0e                	jmp    800d0b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800cfd:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800d00:	80 fb 19             	cmp    $0x19,%bl
  800d03:	77 15                	ja     800d1a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800d05:	0f be c9             	movsbl %cl,%ecx
  800d08:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800d0b:	39 f1                	cmp    %esi,%ecx
  800d0d:	7d 0b                	jge    800d1a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800d0f:	83 c2 01             	add    $0x1,%edx
  800d12:	0f af c6             	imul   %esi,%eax
  800d15:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800d18:	eb be                	jmp    800cd8 <strtol+0x8d>
  800d1a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800d1c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800d20:	74 05                	je     800d27 <strtol+0xdc>
		*endptr = (char *) s;
  800d22:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800d25:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800d27:	89 ca                	mov    %ecx,%edx
  800d29:	f7 da                	neg    %edx
  800d2b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800d2f:	0f 45 c2             	cmovne %edx,%eax
}
  800d32:	83 c4 04             	add    $0x4,%esp
  800d35:	5b                   	pop    %ebx
  800d36:	5e                   	pop    %esi
  800d37:	5f                   	pop    %edi
  800d38:	5d                   	pop    %ebp
  800d39:	c3                   	ret    
	...

00800d3c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800d3c:	55                   	push   %ebp
  800d3d:	89 e5                	mov    %esp,%ebp
  800d3f:	83 ec 0c             	sub    $0xc,%esp
  800d42:	89 1c 24             	mov    %ebx,(%esp)
  800d45:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d49:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d4d:	ba 00 00 00 00       	mov    $0x0,%edx
  800d52:	b8 01 00 00 00       	mov    $0x1,%eax
  800d57:	89 d1                	mov    %edx,%ecx
  800d59:	89 d3                	mov    %edx,%ebx
  800d5b:	89 d7                	mov    %edx,%edi
  800d5d:	89 d6                	mov    %edx,%esi
  800d5f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800d61:	8b 1c 24             	mov    (%esp),%ebx
  800d64:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d68:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d6c:	89 ec                	mov    %ebp,%esp
  800d6e:	5d                   	pop    %ebp
  800d6f:	c3                   	ret    

00800d70 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800d70:	55                   	push   %ebp
  800d71:	89 e5                	mov    %esp,%ebp
  800d73:	83 ec 0c             	sub    $0xc,%esp
  800d76:	89 1c 24             	mov    %ebx,(%esp)
  800d79:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d7d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d81:	b8 00 00 00 00       	mov    $0x0,%eax
  800d86:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800d89:	8b 55 08             	mov    0x8(%ebp),%edx
  800d8c:	89 c3                	mov    %eax,%ebx
  800d8e:	89 c7                	mov    %eax,%edi
  800d90:	89 c6                	mov    %eax,%esi
  800d92:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800d94:	8b 1c 24             	mov    (%esp),%ebx
  800d97:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d9b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d9f:	89 ec                	mov    %ebp,%esp
  800da1:	5d                   	pop    %ebp
  800da2:	c3                   	ret    

00800da3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800da3:	55                   	push   %ebp
  800da4:	89 e5                	mov    %esp,%ebp
  800da6:	83 ec 0c             	sub    $0xc,%esp
  800da9:	89 1c 24             	mov    %ebx,(%esp)
  800dac:	89 74 24 04          	mov    %esi,0x4(%esp)
  800db0:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800db4:	bb 00 00 00 00       	mov    $0x0,%ebx
  800db9:	b8 10 00 00 00       	mov    $0x10,%eax
  800dbe:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800dc1:	8b 55 08             	mov    0x8(%ebp),%edx
  800dc4:	89 df                	mov    %ebx,%edi
  800dc6:	89 de                	mov    %ebx,%esi
  800dc8:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800dca:	8b 1c 24             	mov    (%esp),%ebx
  800dcd:	8b 74 24 04          	mov    0x4(%esp),%esi
  800dd1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800dd5:	89 ec                	mov    %ebp,%esp
  800dd7:	5d                   	pop    %ebp
  800dd8:	c3                   	ret    

00800dd9 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800dd9:	55                   	push   %ebp
  800dda:	89 e5                	mov    %esp,%ebp
  800ddc:	83 ec 0c             	sub    $0xc,%esp
  800ddf:	89 1c 24             	mov    %ebx,(%esp)
  800de2:	89 74 24 04          	mov    %esi,0x4(%esp)
  800de6:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800dea:	bb 00 00 00 00       	mov    $0x0,%ebx
  800def:	b8 0f 00 00 00       	mov    $0xf,%eax
  800df4:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800df7:	8b 55 08             	mov    0x8(%ebp),%edx
  800dfa:	89 df                	mov    %ebx,%edi
  800dfc:	89 de                	mov    %ebx,%esi
  800dfe:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800e00:	8b 1c 24             	mov    (%esp),%ebx
  800e03:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e07:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e0b:	89 ec                	mov    %ebp,%esp
  800e0d:	5d                   	pop    %ebp
  800e0e:	c3                   	ret    

00800e0f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800e0f:	55                   	push   %ebp
  800e10:	89 e5                	mov    %esp,%ebp
  800e12:	83 ec 0c             	sub    $0xc,%esp
  800e15:	89 1c 24             	mov    %ebx,(%esp)
  800e18:	89 74 24 04          	mov    %esi,0x4(%esp)
  800e1c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e20:	ba 00 00 00 00       	mov    $0x0,%edx
  800e25:	b8 0e 00 00 00       	mov    $0xe,%eax
  800e2a:	89 d1                	mov    %edx,%ecx
  800e2c:	89 d3                	mov    %edx,%ebx
  800e2e:	89 d7                	mov    %edx,%edi
  800e30:	89 d6                	mov    %edx,%esi
  800e32:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800e34:	8b 1c 24             	mov    (%esp),%ebx
  800e37:	8b 74 24 04          	mov    0x4(%esp),%esi
  800e3b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800e3f:	89 ec                	mov    %ebp,%esp
  800e41:	5d                   	pop    %ebp
  800e42:	c3                   	ret    

00800e43 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800e43:	55                   	push   %ebp
  800e44:	89 e5                	mov    %esp,%ebp
  800e46:	83 ec 38             	sub    $0x38,%esp
  800e49:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e4c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e4f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e52:	b9 00 00 00 00       	mov    $0x0,%ecx
  800e57:	b8 0d 00 00 00       	mov    $0xd,%eax
  800e5c:	8b 55 08             	mov    0x8(%ebp),%edx
  800e5f:	89 cb                	mov    %ecx,%ebx
  800e61:	89 cf                	mov    %ecx,%edi
  800e63:	89 ce                	mov    %ecx,%esi
  800e65:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800e67:	85 c0                	test   %eax,%eax
  800e69:	7e 28                	jle    800e93 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800e6b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800e6f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800e76:	00 
  800e77:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800e7e:	00 
  800e7f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800e86:	00 
  800e87:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  800e8e:	e8 4d f3 ff ff       	call   8001e0 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800e93:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800e96:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800e99:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800e9c:	89 ec                	mov    %ebp,%esp
  800e9e:	5d                   	pop    %ebp
  800e9f:	c3                   	ret    

00800ea0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800ea0:	55                   	push   %ebp
  800ea1:	89 e5                	mov    %esp,%ebp
  800ea3:	83 ec 38             	sub    $0x38,%esp
  800ea6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ea9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800eac:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800eaf:	be 00 00 00 00       	mov    $0x0,%esi
  800eb4:	b8 0c 00 00 00       	mov    $0xc,%eax
  800eb9:	8b 7d 14             	mov    0x14(%ebp),%edi
  800ebc:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800ebf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ec2:	8b 55 08             	mov    0x8(%ebp),%edx
  800ec5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800ec7:	85 c0                	test   %eax,%eax
  800ec9:	7e 28                	jle    800ef3 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  800ecb:	89 44 24 10          	mov    %eax,0x10(%esp)
  800ecf:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800ed6:	00 
  800ed7:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800ede:	00 
  800edf:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ee6:	00 
  800ee7:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  800eee:	e8 ed f2 ff ff       	call   8001e0 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800ef3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800ef6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ef9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800efc:	89 ec                	mov    %ebp,%esp
  800efe:	5d                   	pop    %ebp
  800eff:	c3                   	ret    

00800f00 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800f00:	55                   	push   %ebp
  800f01:	89 e5                	mov    %esp,%ebp
  800f03:	83 ec 38             	sub    $0x38,%esp
  800f06:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f09:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f0c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f0f:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f14:	b8 0a 00 00 00       	mov    $0xa,%eax
  800f19:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f1c:	8b 55 08             	mov    0x8(%ebp),%edx
  800f1f:	89 df                	mov    %ebx,%edi
  800f21:	89 de                	mov    %ebx,%esi
  800f23:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f25:	85 c0                	test   %eax,%eax
  800f27:	7e 28                	jle    800f51 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f29:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f2d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800f34:	00 
  800f35:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800f3c:	00 
  800f3d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f44:	00 
  800f45:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  800f4c:	e8 8f f2 ff ff       	call   8001e0 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800f51:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f54:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f57:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f5a:	89 ec                	mov    %ebp,%esp
  800f5c:	5d                   	pop    %ebp
  800f5d:	c3                   	ret    

00800f5e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800f5e:	55                   	push   %ebp
  800f5f:	89 e5                	mov    %esp,%ebp
  800f61:	83 ec 38             	sub    $0x38,%esp
  800f64:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f67:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f6a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f6d:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f72:	b8 09 00 00 00       	mov    $0x9,%eax
  800f77:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f7a:	8b 55 08             	mov    0x8(%ebp),%edx
  800f7d:	89 df                	mov    %ebx,%edi
  800f7f:	89 de                	mov    %ebx,%esi
  800f81:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f83:	85 c0                	test   %eax,%eax
  800f85:	7e 28                	jle    800faf <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f87:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f8b:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  800f92:	00 
  800f93:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800f9a:	00 
  800f9b:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800fa2:	00 
  800fa3:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  800faa:	e8 31 f2 ff ff       	call   8001e0 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800faf:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800fb2:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800fb5:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800fb8:	89 ec                	mov    %ebp,%esp
  800fba:	5d                   	pop    %ebp
  800fbb:	c3                   	ret    

00800fbc <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  800fbc:	55                   	push   %ebp
  800fbd:	89 e5                	mov    %esp,%ebp
  800fbf:	83 ec 38             	sub    $0x38,%esp
  800fc2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fc5:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fc8:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fcb:	bb 00 00 00 00       	mov    $0x0,%ebx
  800fd0:	b8 08 00 00 00       	mov    $0x8,%eax
  800fd5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fd8:	8b 55 08             	mov    0x8(%ebp),%edx
  800fdb:	89 df                	mov    %ebx,%edi
  800fdd:	89 de                	mov    %ebx,%esi
  800fdf:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fe1:	85 c0                	test   %eax,%eax
  800fe3:	7e 28                	jle    80100d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fe5:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fe9:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  800ff0:	00 
  800ff1:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  800ff8:	00 
  800ff9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801000:	00 
  801001:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  801008:	e8 d3 f1 ff ff       	call   8001e0 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  80100d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801010:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801013:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801016:	89 ec                	mov    %ebp,%esp
  801018:	5d                   	pop    %ebp
  801019:	c3                   	ret    

0080101a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  80101a:	55                   	push   %ebp
  80101b:	89 e5                	mov    %esp,%ebp
  80101d:	83 ec 38             	sub    $0x38,%esp
  801020:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801023:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801026:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801029:	bb 00 00 00 00       	mov    $0x0,%ebx
  80102e:	b8 06 00 00 00       	mov    $0x6,%eax
  801033:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801036:	8b 55 08             	mov    0x8(%ebp),%edx
  801039:	89 df                	mov    %ebx,%edi
  80103b:	89 de                	mov    %ebx,%esi
  80103d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80103f:	85 c0                	test   %eax,%eax
  801041:	7e 28                	jle    80106b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  801043:	89 44 24 10          	mov    %eax,0x10(%esp)
  801047:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  80104e:	00 
  80104f:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  801056:	00 
  801057:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80105e:	00 
  80105f:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  801066:	e8 75 f1 ff ff       	call   8001e0 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  80106b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80106e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801071:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801074:	89 ec                	mov    %ebp,%esp
  801076:	5d                   	pop    %ebp
  801077:	c3                   	ret    

00801078 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  801078:	55                   	push   %ebp
  801079:	89 e5                	mov    %esp,%ebp
  80107b:	83 ec 38             	sub    $0x38,%esp
  80107e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801081:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801084:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801087:	b8 05 00 00 00       	mov    $0x5,%eax
  80108c:	8b 75 18             	mov    0x18(%ebp),%esi
  80108f:	8b 7d 14             	mov    0x14(%ebp),%edi
  801092:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801095:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801098:	8b 55 08             	mov    0x8(%ebp),%edx
  80109b:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80109d:	85 c0                	test   %eax,%eax
  80109f:	7e 28                	jle    8010c9 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010a1:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010a5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  8010ac:	00 
  8010ad:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  8010b4:	00 
  8010b5:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8010bc:	00 
  8010bd:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  8010c4:	e8 17 f1 ff ff       	call   8001e0 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  8010c9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8010cc:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8010cf:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8010d2:	89 ec                	mov    %ebp,%esp
  8010d4:	5d                   	pop    %ebp
  8010d5:	c3                   	ret    

008010d6 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  8010d6:	55                   	push   %ebp
  8010d7:	89 e5                	mov    %esp,%ebp
  8010d9:	83 ec 38             	sub    $0x38,%esp
  8010dc:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010df:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010e2:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010e5:	be 00 00 00 00       	mov    $0x0,%esi
  8010ea:	b8 04 00 00 00       	mov    $0x4,%eax
  8010ef:	8b 5d 10             	mov    0x10(%ebp),%ebx
  8010f2:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  8010f5:	8b 55 08             	mov    0x8(%ebp),%edx
  8010f8:	89 f7                	mov    %esi,%edi
  8010fa:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010fc:	85 c0                	test   %eax,%eax
  8010fe:	7e 28                	jle    801128 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801100:	89 44 24 10          	mov    %eax,0x10(%esp)
  801104:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80110b:	00 
  80110c:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  801113:	00 
  801114:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80111b:	00 
  80111c:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  801123:	e8 b8 f0 ff ff       	call   8001e0 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801128:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80112b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80112e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801131:	89 ec                	mov    %ebp,%esp
  801133:	5d                   	pop    %ebp
  801134:	c3                   	ret    

00801135 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801135:	55                   	push   %ebp
  801136:	89 e5                	mov    %esp,%ebp
  801138:	83 ec 0c             	sub    $0xc,%esp
  80113b:	89 1c 24             	mov    %ebx,(%esp)
  80113e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801142:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801146:	ba 00 00 00 00       	mov    $0x0,%edx
  80114b:	b8 0b 00 00 00       	mov    $0xb,%eax
  801150:	89 d1                	mov    %edx,%ecx
  801152:	89 d3                	mov    %edx,%ebx
  801154:	89 d7                	mov    %edx,%edi
  801156:	89 d6                	mov    %edx,%esi
  801158:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80115a:	8b 1c 24             	mov    (%esp),%ebx
  80115d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801161:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801165:	89 ec                	mov    %ebp,%esp
  801167:	5d                   	pop    %ebp
  801168:	c3                   	ret    

00801169 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801169:	55                   	push   %ebp
  80116a:	89 e5                	mov    %esp,%ebp
  80116c:	83 ec 0c             	sub    $0xc,%esp
  80116f:	89 1c 24             	mov    %ebx,(%esp)
  801172:	89 74 24 04          	mov    %esi,0x4(%esp)
  801176:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80117a:	ba 00 00 00 00       	mov    $0x0,%edx
  80117f:	b8 02 00 00 00       	mov    $0x2,%eax
  801184:	89 d1                	mov    %edx,%ecx
  801186:	89 d3                	mov    %edx,%ebx
  801188:	89 d7                	mov    %edx,%edi
  80118a:	89 d6                	mov    %edx,%esi
  80118c:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  80118e:	8b 1c 24             	mov    (%esp),%ebx
  801191:	8b 74 24 04          	mov    0x4(%esp),%esi
  801195:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801199:	89 ec                	mov    %ebp,%esp
  80119b:	5d                   	pop    %ebp
  80119c:	c3                   	ret    

0080119d <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  80119d:	55                   	push   %ebp
  80119e:	89 e5                	mov    %esp,%ebp
  8011a0:	83 ec 38             	sub    $0x38,%esp
  8011a3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8011a6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8011a9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8011ac:	b9 00 00 00 00       	mov    $0x0,%ecx
  8011b1:	b8 03 00 00 00       	mov    $0x3,%eax
  8011b6:	8b 55 08             	mov    0x8(%ebp),%edx
  8011b9:	89 cb                	mov    %ecx,%ebx
  8011bb:	89 cf                	mov    %ecx,%edi
  8011bd:	89 ce                	mov    %ecx,%esi
  8011bf:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8011c1:	85 c0                	test   %eax,%eax
  8011c3:	7e 28                	jle    8011ed <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8011c5:	89 44 24 10          	mov    %eax,0x10(%esp)
  8011c9:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  8011d0:	00 
  8011d1:	c7 44 24 08 0b 2e 80 	movl   $0x802e0b,0x8(%esp)
  8011d8:	00 
  8011d9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  8011e0:	00 
  8011e1:	c7 04 24 28 2e 80 00 	movl   $0x802e28,(%esp)
  8011e8:	e8 f3 ef ff ff       	call   8001e0 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  8011ed:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8011f0:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8011f3:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8011f6:	89 ec                	mov    %ebp,%esp
  8011f8:	5d                   	pop    %ebp
  8011f9:	c3                   	ret    
  8011fa:	00 00                	add    %al,(%eax)
  8011fc:	00 00                	add    %al,(%eax)
	...

00801200 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801200:	55                   	push   %ebp
  801201:	89 e5                	mov    %esp,%ebp
  801203:	8b 45 08             	mov    0x8(%ebp),%eax
  801206:	05 00 00 00 30       	add    $0x30000000,%eax
  80120b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80120e:	5d                   	pop    %ebp
  80120f:	c3                   	ret    

00801210 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801210:	55                   	push   %ebp
  801211:	89 e5                	mov    %esp,%ebp
  801213:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801216:	8b 45 08             	mov    0x8(%ebp),%eax
  801219:	89 04 24             	mov    %eax,(%esp)
  80121c:	e8 df ff ff ff       	call   801200 <fd2num>
  801221:	05 20 00 0d 00       	add    $0xd0020,%eax
  801226:	c1 e0 0c             	shl    $0xc,%eax
}
  801229:	c9                   	leave  
  80122a:	c3                   	ret    

0080122b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80122b:	55                   	push   %ebp
  80122c:	89 e5                	mov    %esp,%ebp
  80122e:	57                   	push   %edi
  80122f:	56                   	push   %esi
  801230:	53                   	push   %ebx
  801231:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801234:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801239:	a8 01                	test   $0x1,%al
  80123b:	74 36                	je     801273 <fd_alloc+0x48>
  80123d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801242:	a8 01                	test   $0x1,%al
  801244:	74 2d                	je     801273 <fd_alloc+0x48>
  801246:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80124b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  801250:	be 00 00 40 ef       	mov    $0xef400000,%esi
  801255:	89 c3                	mov    %eax,%ebx
  801257:	89 c2                	mov    %eax,%edx
  801259:	c1 ea 16             	shr    $0x16,%edx
  80125c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  80125f:	f6 c2 01             	test   $0x1,%dl
  801262:	74 14                	je     801278 <fd_alloc+0x4d>
  801264:	89 c2                	mov    %eax,%edx
  801266:	c1 ea 0c             	shr    $0xc,%edx
  801269:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80126c:	f6 c2 01             	test   $0x1,%dl
  80126f:	75 10                	jne    801281 <fd_alloc+0x56>
  801271:	eb 05                	jmp    801278 <fd_alloc+0x4d>
  801273:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801278:	89 1f                	mov    %ebx,(%edi)
  80127a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80127f:	eb 17                	jmp    801298 <fd_alloc+0x6d>
  801281:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  801286:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  80128b:	75 c8                	jne    801255 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  80128d:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  801293:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  801298:	5b                   	pop    %ebx
  801299:	5e                   	pop    %esi
  80129a:	5f                   	pop    %edi
  80129b:	5d                   	pop    %ebp
  80129c:	c3                   	ret    

0080129d <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  80129d:	55                   	push   %ebp
  80129e:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8012a0:	8b 45 08             	mov    0x8(%ebp),%eax
  8012a3:	83 f8 1f             	cmp    $0x1f,%eax
  8012a6:	77 36                	ja     8012de <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8012a8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8012ad:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  8012b0:	89 c2                	mov    %eax,%edx
  8012b2:	c1 ea 16             	shr    $0x16,%edx
  8012b5:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8012bc:	f6 c2 01             	test   $0x1,%dl
  8012bf:	74 1d                	je     8012de <fd_lookup+0x41>
  8012c1:	89 c2                	mov    %eax,%edx
  8012c3:	c1 ea 0c             	shr    $0xc,%edx
  8012c6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8012cd:	f6 c2 01             	test   $0x1,%dl
  8012d0:	74 0c                	je     8012de <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  8012d2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8012d5:	89 02                	mov    %eax,(%edx)
  8012d7:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  8012dc:	eb 05                	jmp    8012e3 <fd_lookup+0x46>
  8012de:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8012e3:	5d                   	pop    %ebp
  8012e4:	c3                   	ret    

008012e5 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  8012e5:	55                   	push   %ebp
  8012e6:	89 e5                	mov    %esp,%ebp
  8012e8:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8012eb:	8d 45 fc             	lea    -0x4(%ebp),%eax
  8012ee:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012f2:	8b 45 08             	mov    0x8(%ebp),%eax
  8012f5:	89 04 24             	mov    %eax,(%esp)
  8012f8:	e8 a0 ff ff ff       	call   80129d <fd_lookup>
  8012fd:	85 c0                	test   %eax,%eax
  8012ff:	78 0e                	js     80130f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801301:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801304:	8b 55 0c             	mov    0xc(%ebp),%edx
  801307:	89 50 04             	mov    %edx,0x4(%eax)
  80130a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80130f:	c9                   	leave  
  801310:	c3                   	ret    

00801311 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801311:	55                   	push   %ebp
  801312:	89 e5                	mov    %esp,%ebp
  801314:	56                   	push   %esi
  801315:	53                   	push   %ebx
  801316:	83 ec 10             	sub    $0x10,%esp
  801319:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80131c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80131f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801324:	b8 04 60 80 00       	mov    $0x806004,%eax
  801329:	39 0d 04 60 80 00    	cmp    %ecx,0x806004
  80132f:	75 11                	jne    801342 <dev_lookup+0x31>
  801331:	eb 04                	jmp    801337 <dev_lookup+0x26>
  801333:	39 08                	cmp    %ecx,(%eax)
  801335:	75 10                	jne    801347 <dev_lookup+0x36>
			*dev = devtab[i];
  801337:	89 03                	mov    %eax,(%ebx)
  801339:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80133e:	66 90                	xchg   %ax,%ax
  801340:	eb 36                	jmp    801378 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801342:	be b4 2e 80 00       	mov    $0x802eb4,%esi
  801347:	83 c2 01             	add    $0x1,%edx
  80134a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80134d:	85 c0                	test   %eax,%eax
  80134f:	75 e2                	jne    801333 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  801351:	a1 80 80 80 00       	mov    0x808080,%eax
  801356:	8b 40 4c             	mov    0x4c(%eax),%eax
  801359:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80135d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801361:	c7 04 24 38 2e 80 00 	movl   $0x802e38,(%esp)
  801368:	e8 38 ef ff ff       	call   8002a5 <cprintf>
	*dev = 0;
  80136d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801373:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801378:	83 c4 10             	add    $0x10,%esp
  80137b:	5b                   	pop    %ebx
  80137c:	5e                   	pop    %esi
  80137d:	5d                   	pop    %ebp
  80137e:	c3                   	ret    

0080137f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80137f:	55                   	push   %ebp
  801380:	89 e5                	mov    %esp,%ebp
  801382:	53                   	push   %ebx
  801383:	83 ec 24             	sub    $0x24,%esp
  801386:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801389:	8d 45 f0             	lea    -0x10(%ebp),%eax
  80138c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801390:	8b 45 08             	mov    0x8(%ebp),%eax
  801393:	89 04 24             	mov    %eax,(%esp)
  801396:	e8 02 ff ff ff       	call   80129d <fd_lookup>
  80139b:	85 c0                	test   %eax,%eax
  80139d:	78 53                	js     8013f2 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  80139f:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8013a2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8013a6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8013a9:	8b 00                	mov    (%eax),%eax
  8013ab:	89 04 24             	mov    %eax,(%esp)
  8013ae:	e8 5e ff ff ff       	call   801311 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8013b3:	85 c0                	test   %eax,%eax
  8013b5:	78 3b                	js     8013f2 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  8013b7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8013bc:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8013bf:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  8013c3:	74 2d                	je     8013f2 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8013c5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8013c8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8013cf:	00 00 00 
	stat->st_isdir = 0;
  8013d2:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8013d9:	00 00 00 
	stat->st_dev = dev;
  8013dc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8013df:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  8013e5:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8013e9:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8013ec:	89 14 24             	mov    %edx,(%esp)
  8013ef:	ff 50 14             	call   *0x14(%eax)
}
  8013f2:	83 c4 24             	add    $0x24,%esp
  8013f5:	5b                   	pop    %ebx
  8013f6:	5d                   	pop    %ebp
  8013f7:	c3                   	ret    

008013f8 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  8013f8:	55                   	push   %ebp
  8013f9:	89 e5                	mov    %esp,%ebp
  8013fb:	53                   	push   %ebx
  8013fc:	83 ec 24             	sub    $0x24,%esp
  8013ff:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801402:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801405:	89 44 24 04          	mov    %eax,0x4(%esp)
  801409:	89 1c 24             	mov    %ebx,(%esp)
  80140c:	e8 8c fe ff ff       	call   80129d <fd_lookup>
  801411:	85 c0                	test   %eax,%eax
  801413:	78 5f                	js     801474 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801415:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801418:	89 44 24 04          	mov    %eax,0x4(%esp)
  80141c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80141f:	8b 00                	mov    (%eax),%eax
  801421:	89 04 24             	mov    %eax,(%esp)
  801424:	e8 e8 fe ff ff       	call   801311 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801429:	85 c0                	test   %eax,%eax
  80142b:	78 47                	js     801474 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80142d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801430:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801434:	75 23                	jne    801459 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801436:	a1 80 80 80 00       	mov    0x808080,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80143b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80143e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801442:	89 44 24 04          	mov    %eax,0x4(%esp)
  801446:	c7 04 24 58 2e 80 00 	movl   $0x802e58,(%esp)
  80144d:	e8 53 ee ff ff       	call   8002a5 <cprintf>
  801452:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801457:	eb 1b                	jmp    801474 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801459:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80145c:	8b 48 18             	mov    0x18(%eax),%ecx
  80145f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801464:	85 c9                	test   %ecx,%ecx
  801466:	74 0c                	je     801474 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801468:	8b 45 0c             	mov    0xc(%ebp),%eax
  80146b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80146f:	89 14 24             	mov    %edx,(%esp)
  801472:	ff d1                	call   *%ecx
}
  801474:	83 c4 24             	add    $0x24,%esp
  801477:	5b                   	pop    %ebx
  801478:	5d                   	pop    %ebp
  801479:	c3                   	ret    

0080147a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80147a:	55                   	push   %ebp
  80147b:	89 e5                	mov    %esp,%ebp
  80147d:	53                   	push   %ebx
  80147e:	83 ec 24             	sub    $0x24,%esp
  801481:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801484:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801487:	89 44 24 04          	mov    %eax,0x4(%esp)
  80148b:	89 1c 24             	mov    %ebx,(%esp)
  80148e:	e8 0a fe ff ff       	call   80129d <fd_lookup>
  801493:	85 c0                	test   %eax,%eax
  801495:	78 66                	js     8014fd <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801497:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80149a:	89 44 24 04          	mov    %eax,0x4(%esp)
  80149e:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8014a1:	8b 00                	mov    (%eax),%eax
  8014a3:	89 04 24             	mov    %eax,(%esp)
  8014a6:	e8 66 fe ff ff       	call   801311 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8014ab:	85 c0                	test   %eax,%eax
  8014ad:	78 4e                	js     8014fd <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8014af:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8014b2:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8014b6:	75 23                	jne    8014db <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  8014b8:	a1 80 80 80 00       	mov    0x808080,%eax
  8014bd:	8b 40 4c             	mov    0x4c(%eax),%eax
  8014c0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8014c4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014c8:	c7 04 24 79 2e 80 00 	movl   $0x802e79,(%esp)
  8014cf:	e8 d1 ed ff ff       	call   8002a5 <cprintf>
  8014d4:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8014d9:	eb 22                	jmp    8014fd <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8014db:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8014de:	8b 48 0c             	mov    0xc(%eax),%ecx
  8014e1:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8014e6:	85 c9                	test   %ecx,%ecx
  8014e8:	74 13                	je     8014fd <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  8014ea:	8b 45 10             	mov    0x10(%ebp),%eax
  8014ed:	89 44 24 08          	mov    %eax,0x8(%esp)
  8014f1:	8b 45 0c             	mov    0xc(%ebp),%eax
  8014f4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8014f8:	89 14 24             	mov    %edx,(%esp)
  8014fb:	ff d1                	call   *%ecx
}
  8014fd:	83 c4 24             	add    $0x24,%esp
  801500:	5b                   	pop    %ebx
  801501:	5d                   	pop    %ebp
  801502:	c3                   	ret    

00801503 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801503:	55                   	push   %ebp
  801504:	89 e5                	mov    %esp,%ebp
  801506:	57                   	push   %edi
  801507:	56                   	push   %esi
  801508:	53                   	push   %ebx
  801509:	83 ec 2c             	sub    $0x2c,%esp
  80150c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80150f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801512:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801515:	89 44 24 04          	mov    %eax,0x4(%esp)
  801519:	89 1c 24             	mov    %ebx,(%esp)
  80151c:	e8 7c fd ff ff       	call   80129d <fd_lookup>
  801521:	85 c0                	test   %eax,%eax
  801523:	0f 88 b0 00 00 00    	js     8015d9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801529:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80152c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801530:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801533:	8b 00                	mov    (%eax),%eax
  801535:	89 04 24             	mov    %eax,(%esp)
  801538:	e8 d4 fd ff ff       	call   801311 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80153d:	85 c0                	test   %eax,%eax
  80153f:	0f 88 94 00 00 00    	js     8015d9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801545:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801548:	8b 40 08             	mov    0x8(%eax),%eax
  80154b:	83 e0 03             	and    $0x3,%eax
  80154e:	83 f8 01             	cmp    $0x1,%eax
  801551:	75 23                	jne    801576 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801553:	a1 80 80 80 00       	mov    0x808080,%eax
  801558:	8b 40 4c             	mov    0x4c(%eax),%eax
  80155b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80155f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801563:	c7 04 24 96 2e 80 00 	movl   $0x802e96,(%esp)
  80156a:	e8 36 ed ff ff       	call   8002a5 <cprintf>
  80156f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801574:	eb 63                	jmp    8015d9 <read+0xd6>
	}
	if (!dev->dev_read)
  801576:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80157b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80157e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  801582:	74 55                	je     8015d9 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  801584:	ba 00 00 00 00       	mov    $0x0,%edx
  801589:	bb 00 00 00 00       	mov    $0x0,%ebx
  80158e:	b8 00 00 00 00       	mov    $0x0,%eax
  801593:	85 f6                	test   %esi,%esi
  801595:	74 42                	je     8015d9 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  801597:	bf 00 10 00 00       	mov    $0x1000,%edi
  80159c:	89 f0                	mov    %esi,%eax
  80159e:	29 d0                	sub    %edx,%eax
  8015a0:	89 c1                	mov    %eax,%ecx
  8015a2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  8015a8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8015ad:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  8015b0:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8015b4:	03 55 0c             	add    0xc(%ebp),%edx
  8015b7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8015bb:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8015be:	89 04 24             	mov    %eax,(%esp)
  8015c1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8015c4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  8015c7:	85 c0                	test   %eax,%eax
  8015c9:	78 0e                	js     8015d9 <read+0xd6>
			return m;
		if (m == 0)
  8015cb:	85 c0                	test   %eax,%eax
  8015cd:	74 08                	je     8015d7 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8015cf:	01 c3                	add    %eax,%ebx
  8015d1:	89 da                	mov    %ebx,%edx
  8015d3:	39 f3                	cmp    %esi,%ebx
  8015d5:	72 c5                	jb     80159c <read+0x99>
  8015d7:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  8015d9:	83 c4 2c             	add    $0x2c,%esp
  8015dc:	5b                   	pop    %ebx
  8015dd:	5e                   	pop    %esi
  8015de:	5f                   	pop    %edi
  8015df:	5d                   	pop    %ebp
  8015e0:	c3                   	ret    

008015e1 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  8015e1:	55                   	push   %ebp
  8015e2:	89 e5                	mov    %esp,%ebp
  8015e4:	57                   	push   %edi
  8015e5:	56                   	push   %esi
  8015e6:	53                   	push   %ebx
  8015e7:	83 ec 1c             	sub    $0x1c,%esp
  8015ea:	8b 7d 08             	mov    0x8(%ebp),%edi
  8015ed:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  8015f0:	ba 00 00 00 00       	mov    $0x0,%edx
  8015f5:	bb 00 00 00 00       	mov    $0x0,%ebx
  8015fa:	b8 00 00 00 00       	mov    $0x0,%eax
  8015ff:	85 f6                	test   %esi,%esi
  801601:	74 29                	je     80162c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801603:	89 f0                	mov    %esi,%eax
  801605:	29 d0                	sub    %edx,%eax
  801607:	89 44 24 08          	mov    %eax,0x8(%esp)
  80160b:	03 55 0c             	add    0xc(%ebp),%edx
  80160e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801612:	89 3c 24             	mov    %edi,(%esp)
  801615:	e8 e9 fe ff ff       	call   801503 <read>
		if (m < 0)
  80161a:	85 c0                	test   %eax,%eax
  80161c:	78 0e                	js     80162c <readn+0x4b>
			return m;
		if (m == 0)
  80161e:	85 c0                	test   %eax,%eax
  801620:	74 08                	je     80162a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801622:	01 c3                	add    %eax,%ebx
  801624:	89 da                	mov    %ebx,%edx
  801626:	39 f3                	cmp    %esi,%ebx
  801628:	72 d9                	jb     801603 <readn+0x22>
  80162a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80162c:	83 c4 1c             	add    $0x1c,%esp
  80162f:	5b                   	pop    %ebx
  801630:	5e                   	pop    %esi
  801631:	5f                   	pop    %edi
  801632:	5d                   	pop    %ebp
  801633:	c3                   	ret    

00801634 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801634:	55                   	push   %ebp
  801635:	89 e5                	mov    %esp,%ebp
  801637:	83 ec 28             	sub    $0x28,%esp
  80163a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80163d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801640:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801643:	89 34 24             	mov    %esi,(%esp)
  801646:	e8 b5 fb ff ff       	call   801200 <fd2num>
  80164b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80164e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801652:	89 04 24             	mov    %eax,(%esp)
  801655:	e8 43 fc ff ff       	call   80129d <fd_lookup>
  80165a:	89 c3                	mov    %eax,%ebx
  80165c:	85 c0                	test   %eax,%eax
  80165e:	78 05                	js     801665 <fd_close+0x31>
  801660:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801663:	74 0e                	je     801673 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801665:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801669:	b8 00 00 00 00       	mov    $0x0,%eax
  80166e:	0f 44 d8             	cmove  %eax,%ebx
  801671:	eb 3d                	jmp    8016b0 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801673:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801676:	89 44 24 04          	mov    %eax,0x4(%esp)
  80167a:	8b 06                	mov    (%esi),%eax
  80167c:	89 04 24             	mov    %eax,(%esp)
  80167f:	e8 8d fc ff ff       	call   801311 <dev_lookup>
  801684:	89 c3                	mov    %eax,%ebx
  801686:	85 c0                	test   %eax,%eax
  801688:	78 16                	js     8016a0 <fd_close+0x6c>
		if (dev->dev_close)
  80168a:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80168d:	8b 40 10             	mov    0x10(%eax),%eax
  801690:	bb 00 00 00 00       	mov    $0x0,%ebx
  801695:	85 c0                	test   %eax,%eax
  801697:	74 07                	je     8016a0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  801699:	89 34 24             	mov    %esi,(%esp)
  80169c:	ff d0                	call   *%eax
  80169e:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  8016a0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8016a4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8016ab:	e8 6a f9 ff ff       	call   80101a <sys_page_unmap>
	return r;
}
  8016b0:	89 d8                	mov    %ebx,%eax
  8016b2:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8016b5:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8016b8:	89 ec                	mov    %ebp,%esp
  8016ba:	5d                   	pop    %ebp
  8016bb:	c3                   	ret    

008016bc <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  8016bc:	55                   	push   %ebp
  8016bd:	89 e5                	mov    %esp,%ebp
  8016bf:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8016c2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8016c5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016c9:	8b 45 08             	mov    0x8(%ebp),%eax
  8016cc:	89 04 24             	mov    %eax,(%esp)
  8016cf:	e8 c9 fb ff ff       	call   80129d <fd_lookup>
  8016d4:	85 c0                	test   %eax,%eax
  8016d6:	78 13                	js     8016eb <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  8016d8:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8016df:	00 
  8016e0:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8016e3:	89 04 24             	mov    %eax,(%esp)
  8016e6:	e8 49 ff ff ff       	call   801634 <fd_close>
}
  8016eb:	c9                   	leave  
  8016ec:	c3                   	ret    

008016ed <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  8016ed:	55                   	push   %ebp
  8016ee:	89 e5                	mov    %esp,%ebp
  8016f0:	83 ec 18             	sub    $0x18,%esp
  8016f3:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8016f6:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  8016f9:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801700:	00 
  801701:	8b 45 08             	mov    0x8(%ebp),%eax
  801704:	89 04 24             	mov    %eax,(%esp)
  801707:	e8 80 03 00 00       	call   801a8c <open>
  80170c:	89 c3                	mov    %eax,%ebx
  80170e:	85 c0                	test   %eax,%eax
  801710:	78 1b                	js     80172d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801712:	8b 45 0c             	mov    0xc(%ebp),%eax
  801715:	89 44 24 04          	mov    %eax,0x4(%esp)
  801719:	89 1c 24             	mov    %ebx,(%esp)
  80171c:	e8 5e fc ff ff       	call   80137f <fstat>
  801721:	89 c6                	mov    %eax,%esi
	close(fd);
  801723:	89 1c 24             	mov    %ebx,(%esp)
  801726:	e8 91 ff ff ff       	call   8016bc <close>
  80172b:	89 f3                	mov    %esi,%ebx
	return r;
}
  80172d:	89 d8                	mov    %ebx,%eax
  80172f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801732:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801735:	89 ec                	mov    %ebp,%esp
  801737:	5d                   	pop    %ebp
  801738:	c3                   	ret    

00801739 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801739:	55                   	push   %ebp
  80173a:	89 e5                	mov    %esp,%ebp
  80173c:	53                   	push   %ebx
  80173d:	83 ec 14             	sub    $0x14,%esp
  801740:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801745:	89 1c 24             	mov    %ebx,(%esp)
  801748:	e8 6f ff ff ff       	call   8016bc <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  80174d:	83 c3 01             	add    $0x1,%ebx
  801750:	83 fb 20             	cmp    $0x20,%ebx
  801753:	75 f0                	jne    801745 <close_all+0xc>
		close(i);
}
  801755:	83 c4 14             	add    $0x14,%esp
  801758:	5b                   	pop    %ebx
  801759:	5d                   	pop    %ebp
  80175a:	c3                   	ret    

0080175b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  80175b:	55                   	push   %ebp
  80175c:	89 e5                	mov    %esp,%ebp
  80175e:	83 ec 58             	sub    $0x58,%esp
  801761:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801764:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801767:	89 7d fc             	mov    %edi,-0x4(%ebp)
  80176a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  80176d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801770:	89 44 24 04          	mov    %eax,0x4(%esp)
  801774:	8b 45 08             	mov    0x8(%ebp),%eax
  801777:	89 04 24             	mov    %eax,(%esp)
  80177a:	e8 1e fb ff ff       	call   80129d <fd_lookup>
  80177f:	89 c3                	mov    %eax,%ebx
  801781:	85 c0                	test   %eax,%eax
  801783:	0f 88 e0 00 00 00    	js     801869 <dup+0x10e>
		return r;
	close(newfdnum);
  801789:	89 3c 24             	mov    %edi,(%esp)
  80178c:	e8 2b ff ff ff       	call   8016bc <close>

	newfd = INDEX2FD(newfdnum);
  801791:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801797:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  80179a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80179d:	89 04 24             	mov    %eax,(%esp)
  8017a0:	e8 6b fa ff ff       	call   801210 <fd2data>
  8017a5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  8017a7:	89 34 24             	mov    %esi,(%esp)
  8017aa:	e8 61 fa ff ff       	call   801210 <fd2data>
  8017af:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  8017b2:	89 da                	mov    %ebx,%edx
  8017b4:	89 d8                	mov    %ebx,%eax
  8017b6:	c1 e8 16             	shr    $0x16,%eax
  8017b9:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8017c0:	a8 01                	test   $0x1,%al
  8017c2:	74 43                	je     801807 <dup+0xac>
  8017c4:	c1 ea 0c             	shr    $0xc,%edx
  8017c7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8017ce:	a8 01                	test   $0x1,%al
  8017d0:	74 35                	je     801807 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  8017d2:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8017d9:	25 07 0e 00 00       	and    $0xe07,%eax
  8017de:	89 44 24 10          	mov    %eax,0x10(%esp)
  8017e2:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  8017e5:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8017e9:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8017f0:	00 
  8017f1:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8017f5:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8017fc:	e8 77 f8 ff ff       	call   801078 <sys_page_map>
  801801:	89 c3                	mov    %eax,%ebx
  801803:	85 c0                	test   %eax,%eax
  801805:	78 3f                	js     801846 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801807:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80180a:	89 c2                	mov    %eax,%edx
  80180c:	c1 ea 0c             	shr    $0xc,%edx
  80180f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801816:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  80181c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801820:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801824:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80182b:	00 
  80182c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801830:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801837:	e8 3c f8 ff ff       	call   801078 <sys_page_map>
  80183c:	89 c3                	mov    %eax,%ebx
  80183e:	85 c0                	test   %eax,%eax
  801840:	78 04                	js     801846 <dup+0xeb>
  801842:	89 fb                	mov    %edi,%ebx
  801844:	eb 23                	jmp    801869 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801846:	89 74 24 04          	mov    %esi,0x4(%esp)
  80184a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801851:	e8 c4 f7 ff ff       	call   80101a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801856:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801859:	89 44 24 04          	mov    %eax,0x4(%esp)
  80185d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801864:	e8 b1 f7 ff ff       	call   80101a <sys_page_unmap>
	return r;
}
  801869:	89 d8                	mov    %ebx,%eax
  80186b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80186e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801871:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801874:	89 ec                	mov    %ebp,%esp
  801876:	5d                   	pop    %ebp
  801877:	c3                   	ret    

00801878 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801878:	55                   	push   %ebp
  801879:	89 e5                	mov    %esp,%ebp
  80187b:	53                   	push   %ebx
  80187c:	83 ec 14             	sub    $0x14,%esp
  80187f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801881:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801887:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  80188e:	00 
  80188f:	c7 44 24 08 00 30 80 	movl   $0x803000,0x8(%esp)
  801896:	00 
  801897:	89 44 24 04          	mov    %eax,0x4(%esp)
  80189b:	89 14 24             	mov    %edx,(%esp)
  80189e:	e8 2d 0e 00 00       	call   8026d0 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  8018a3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8018aa:	00 
  8018ab:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8018af:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8018b6:	e8 87 0e 00 00       	call   802742 <ipc_recv>
}
  8018bb:	83 c4 14             	add    $0x14,%esp
  8018be:	5b                   	pop    %ebx
  8018bf:	5d                   	pop    %ebp
  8018c0:	c3                   	ret    

008018c1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  8018c1:	55                   	push   %ebp
  8018c2:	89 e5                	mov    %esp,%ebp
  8018c4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  8018c7:	8b 45 08             	mov    0x8(%ebp),%eax
  8018ca:	8b 40 0c             	mov    0xc(%eax),%eax
  8018cd:	a3 00 30 80 00       	mov    %eax,0x803000
	fsipcbuf.set_size.req_size = newsize;
  8018d2:	8b 45 0c             	mov    0xc(%ebp),%eax
  8018d5:	a3 04 30 80 00       	mov    %eax,0x803004
	return fsipc(FSREQ_SET_SIZE, NULL);
  8018da:	ba 00 00 00 00       	mov    $0x0,%edx
  8018df:	b8 02 00 00 00       	mov    $0x2,%eax
  8018e4:	e8 8f ff ff ff       	call   801878 <fsipc>
}
  8018e9:	c9                   	leave  
  8018ea:	c3                   	ret    

008018eb <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  8018eb:	55                   	push   %ebp
  8018ec:	89 e5                	mov    %esp,%ebp
  8018ee:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  8018f1:	8b 45 08             	mov    0x8(%ebp),%eax
  8018f4:	8b 40 0c             	mov    0xc(%eax),%eax
  8018f7:	a3 00 30 80 00       	mov    %eax,0x803000
	return fsipc(FSREQ_FLUSH, NULL);
  8018fc:	ba 00 00 00 00       	mov    $0x0,%edx
  801901:	b8 06 00 00 00       	mov    $0x6,%eax
  801906:	e8 6d ff ff ff       	call   801878 <fsipc>
}
  80190b:	c9                   	leave  
  80190c:	c3                   	ret    

0080190d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  80190d:	55                   	push   %ebp
  80190e:	89 e5                	mov    %esp,%ebp
  801910:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801913:	ba 00 00 00 00       	mov    $0x0,%edx
  801918:	b8 08 00 00 00       	mov    $0x8,%eax
  80191d:	e8 56 ff ff ff       	call   801878 <fsipc>
}
  801922:	c9                   	leave  
  801923:	c3                   	ret    

00801924 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801924:	55                   	push   %ebp
  801925:	89 e5                	mov    %esp,%ebp
  801927:	53                   	push   %ebx
  801928:	83 ec 14             	sub    $0x14,%esp
  80192b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  80192e:	8b 45 08             	mov    0x8(%ebp),%eax
  801931:	8b 40 0c             	mov    0xc(%eax),%eax
  801934:	a3 00 30 80 00       	mov    %eax,0x803000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801939:	ba 00 00 00 00       	mov    $0x0,%edx
  80193e:	b8 05 00 00 00       	mov    $0x5,%eax
  801943:	e8 30 ff ff ff       	call   801878 <fsipc>
  801948:	85 c0                	test   %eax,%eax
  80194a:	78 2b                	js     801977 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  80194c:	c7 44 24 04 00 30 80 	movl   $0x803000,0x4(%esp)
  801953:	00 
  801954:	89 1c 24             	mov    %ebx,(%esp)
  801957:	e8 1e f0 ff ff       	call   80097a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  80195c:	a1 80 30 80 00       	mov    0x803080,%eax
  801961:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801967:	a1 84 30 80 00       	mov    0x803084,%eax
  80196c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801972:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801977:	83 c4 14             	add    $0x14,%esp
  80197a:	5b                   	pop    %ebx
  80197b:	5d                   	pop    %ebp
  80197c:	c3                   	ret    

0080197d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  80197d:	55                   	push   %ebp
  80197e:	89 e5                	mov    %esp,%ebp
  801980:	53                   	push   %ebx
  801981:	83 ec 14             	sub    $0x14,%esp
  801984:	8b 45 08             	mov    0x8(%ebp),%eax
  801987:	8b 55 0c             	mov    0xc(%ebp),%edx
  80198a:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  80198d:	85 c0                	test   %eax,%eax
  80198f:	74 44                	je     8019d5 <devfile_write+0x58>
  801991:	85 d2                	test   %edx,%edx
  801993:	74 40                	je     8019d5 <devfile_write+0x58>
  801995:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  80199b:	77 38                	ja     8019d5 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  80199d:	8b 40 0c             	mov    0xc(%eax),%eax
  8019a0:	a3 00 30 80 00       	mov    %eax,0x803000
    fsipcbuf.write.req_n        = n;
  8019a5:	89 1d 04 30 80 00    	mov    %ebx,0x803004
    memmove(fsipcbuf.write.req_buf, buf, n);
  8019ab:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8019af:	89 54 24 04          	mov    %edx,0x4(%esp)
  8019b3:	c7 04 24 08 30 80 00 	movl   $0x803008,(%esp)
  8019ba:	e8 76 f1 ff ff       	call   800b35 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  8019bf:	ba 00 00 00 00       	mov    $0x0,%edx
  8019c4:	b8 04 00 00 00       	mov    $0x4,%eax
  8019c9:	e8 aa fe ff ff       	call   801878 <fsipc>
        return r;
    return n;
  8019ce:	85 c0                	test   %eax,%eax
  8019d0:	0f 49 c3             	cmovns %ebx,%eax
  8019d3:	eb 05                	jmp    8019da <devfile_write+0x5d>
  8019d5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  8019da:	83 c4 14             	add    $0x14,%esp
  8019dd:	5b                   	pop    %ebx
  8019de:	5d                   	pop    %ebp
  8019df:	c3                   	ret    

008019e0 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  8019e0:	55                   	push   %ebp
  8019e1:	89 e5                	mov    %esp,%ebp
  8019e3:	83 ec 18             	sub    $0x18,%esp
  8019e6:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8019e9:	89 75 fc             	mov    %esi,-0x4(%ebp)
  8019ec:	8b 45 08             	mov    0x8(%ebp),%eax
  8019ef:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  8019f2:	85 c0                	test   %eax,%eax
  8019f4:	74 04                	je     8019fa <devfile_read+0x1a>
  8019f6:	85 f6                	test   %esi,%esi
  8019f8:	75 07                	jne    801a01 <devfile_read+0x21>
  8019fa:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  8019ff:	eb 39                	jmp    801a3a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801a01:	8b 40 0c             	mov    0xc(%eax),%eax
  801a04:	a3 00 30 80 00       	mov    %eax,0x803000
  fsipcbuf.read.req_n         = n;
  801a09:	8b 45 10             	mov    0x10(%ebp),%eax
  801a0c:	a3 04 30 80 00       	mov    %eax,0x803004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801a11:	ba 00 00 00 00       	mov    $0x0,%edx
  801a16:	b8 03 00 00 00       	mov    $0x3,%eax
  801a1b:	e8 58 fe ff ff       	call   801878 <fsipc>
  801a20:	89 c3                	mov    %eax,%ebx
  801a22:	85 c0                	test   %eax,%eax
  801a24:	78 14                	js     801a3a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801a26:	89 44 24 08          	mov    %eax,0x8(%esp)
  801a2a:	c7 44 24 04 00 30 80 	movl   $0x803000,0x4(%esp)
  801a31:	00 
  801a32:	89 34 24             	mov    %esi,(%esp)
  801a35:	e8 fb f0 ff ff       	call   800b35 <memmove>
  return r;
}
  801a3a:	89 d8                	mov    %ebx,%eax
  801a3c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801a3f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801a42:	89 ec                	mov    %ebp,%esp
  801a44:	5d                   	pop    %ebp
  801a45:	c3                   	ret    

00801a46 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801a46:	55                   	push   %ebp
  801a47:	89 e5                	mov    %esp,%ebp
  801a49:	53                   	push   %ebx
  801a4a:	83 ec 14             	sub    $0x14,%esp
  801a4d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801a50:	89 1c 24             	mov    %ebx,(%esp)
  801a53:	e8 d8 ee ff ff       	call   800930 <strlen>
  801a58:	89 c2                	mov    %eax,%edx
  801a5a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801a5f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801a65:	7f 1f                	jg     801a86 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801a67:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801a6b:	c7 04 24 00 30 80 00 	movl   $0x803000,(%esp)
  801a72:	e8 03 ef ff ff       	call   80097a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801a77:	ba 00 00 00 00       	mov    $0x0,%edx
  801a7c:	b8 07 00 00 00       	mov    $0x7,%eax
  801a81:	e8 f2 fd ff ff       	call   801878 <fsipc>
}
  801a86:	83 c4 14             	add    $0x14,%esp
  801a89:	5b                   	pop    %ebx
  801a8a:	5d                   	pop    %ebp
  801a8b:	c3                   	ret    

00801a8c <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801a8c:	55                   	push   %ebp
  801a8d:	89 e5                	mov    %esp,%ebp
  801a8f:	83 ec 28             	sub    $0x28,%esp
  801a92:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801a95:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801a98:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801a9b:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801aa0:	85 f6                	test   %esi,%esi
  801aa2:	74 65                	je     801b09 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801aa4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801aab:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801aae:	89 04 24             	mov    %eax,(%esp)
  801ab1:	e8 75 f7 ff ff       	call   80122b <fd_alloc>
  801ab6:	89 c3                	mov    %eax,%ebx
  801ab8:	85 c0                	test   %eax,%eax
  801aba:	78 4d                	js     801b09 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801abc:	89 74 24 04          	mov    %esi,0x4(%esp)
  801ac0:	c7 04 24 00 30 80 00 	movl   $0x803000,(%esp)
  801ac7:	e8 ae ee ff ff       	call   80097a <strcpy>
	fsipcbuf.open.req_omode = mode;
  801acc:	8b 45 0c             	mov    0xc(%ebp),%eax
  801acf:	a3 00 34 80 00       	mov    %eax,0x803400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801ad4:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801ad7:	b8 01 00 00 00       	mov    $0x1,%eax
  801adc:	e8 97 fd ff ff       	call   801878 <fsipc>
  801ae1:	89 c3                	mov    %eax,%ebx
  801ae3:	85 c0                	test   %eax,%eax
  801ae5:	79 15                	jns    801afc <open+0x70>
    fd_close(f, 0);
  801ae7:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801aee:	00 
  801aef:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801af2:	89 04 24             	mov    %eax,(%esp)
  801af5:	e8 3a fb ff ff       	call   801634 <fd_close>
    return r;
  801afa:	eb 0d                	jmp    801b09 <open+0x7d>
  }
  return fd2num(f);
  801afc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801aff:	89 04 24             	mov    %eax,(%esp)
  801b02:	e8 f9 f6 ff ff       	call   801200 <fd2num>
  801b07:	89 c3                	mov    %eax,%ebx
}
  801b09:	89 d8                	mov    %ebx,%eax
  801b0b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801b0e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801b11:	89 ec                	mov    %ebp,%esp
  801b13:	5d                   	pop    %ebp
  801b14:	c3                   	ret    
  801b15:	00 00                	add    %al,(%eax)
	...

00801b18 <writebuf>:
};


static void
writebuf(struct printbuf *b)
{
  801b18:	55                   	push   %ebp
  801b19:	89 e5                	mov    %esp,%ebp
  801b1b:	53                   	push   %ebx
  801b1c:	83 ec 14             	sub    $0x14,%esp
  801b1f:	89 c3                	mov    %eax,%ebx
	if (b->error > 0) {
  801b21:	83 78 0c 00          	cmpl   $0x0,0xc(%eax)
  801b25:	7e 31                	jle    801b58 <writebuf+0x40>
		ssize_t result = write(b->fd, b->buf, b->idx);
  801b27:	8b 40 04             	mov    0x4(%eax),%eax
  801b2a:	89 44 24 08          	mov    %eax,0x8(%esp)
  801b2e:	8d 43 10             	lea    0x10(%ebx),%eax
  801b31:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b35:	8b 03                	mov    (%ebx),%eax
  801b37:	89 04 24             	mov    %eax,(%esp)
  801b3a:	e8 3b f9 ff ff       	call   80147a <write>
		if (result > 0)
  801b3f:	85 c0                	test   %eax,%eax
  801b41:	7e 03                	jle    801b46 <writebuf+0x2e>
			b->result += result;
  801b43:	01 43 08             	add    %eax,0x8(%ebx)
		if (result != b->idx) // error, or wrote less than supplied
  801b46:	3b 43 04             	cmp    0x4(%ebx),%eax
  801b49:	74 0d                	je     801b58 <writebuf+0x40>
			b->error = (result < 0 ? result : 0);
  801b4b:	85 c0                	test   %eax,%eax
  801b4d:	ba 00 00 00 00       	mov    $0x0,%edx
  801b52:	0f 4f c2             	cmovg  %edx,%eax
  801b55:	89 43 0c             	mov    %eax,0xc(%ebx)
	}
}
  801b58:	83 c4 14             	add    $0x14,%esp
  801b5b:	5b                   	pop    %ebx
  801b5c:	5d                   	pop    %ebp
  801b5d:	c3                   	ret    

00801b5e <vfprintf>:
	}
}

int
vfprintf(int fd, const char *fmt, va_list ap)
{
  801b5e:	55                   	push   %ebp
  801b5f:	89 e5                	mov    %esp,%ebp
  801b61:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.fd = fd;
  801b67:	8b 45 08             	mov    0x8(%ebp),%eax
  801b6a:	89 85 e8 fe ff ff    	mov    %eax,-0x118(%ebp)
	b.idx = 0;
  801b70:	c7 85 ec fe ff ff 00 	movl   $0x0,-0x114(%ebp)
  801b77:	00 00 00 
	b.result = 0;
  801b7a:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  801b81:	00 00 00 
	b.error = 1;
  801b84:	c7 85 f4 fe ff ff 01 	movl   $0x1,-0x10c(%ebp)
  801b8b:	00 00 00 
	vprintfmt(putch, &b, fmt, ap);
  801b8e:	8b 45 10             	mov    0x10(%ebp),%eax
  801b91:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801b95:	8b 45 0c             	mov    0xc(%ebp),%eax
  801b98:	89 44 24 08          	mov    %eax,0x8(%esp)
  801b9c:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  801ba2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ba6:	c7 04 24 1a 1c 80 00 	movl   $0x801c1a,(%esp)
  801bad:	e8 ab e8 ff ff       	call   80045d <vprintfmt>
	if (b.idx > 0)
  801bb2:	83 bd ec fe ff ff 00 	cmpl   $0x0,-0x114(%ebp)
  801bb9:	7e 0b                	jle    801bc6 <vfprintf+0x68>
		writebuf(&b);
  801bbb:	8d 85 e8 fe ff ff    	lea    -0x118(%ebp),%eax
  801bc1:	e8 52 ff ff ff       	call   801b18 <writebuf>

	return (b.result ? b.result : b.error);
  801bc6:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  801bcc:	85 c0                	test   %eax,%eax
  801bce:	0f 44 85 f4 fe ff ff 	cmove  -0x10c(%ebp),%eax
}
  801bd5:	c9                   	leave  
  801bd6:	c3                   	ret    

00801bd7 <printf>:
	return cnt;
}

int
printf(const char *fmt, ...)
{
  801bd7:	55                   	push   %ebp
  801bd8:	89 e5                	mov    %esp,%ebp
  801bda:	83 ec 18             	sub    $0x18,%esp

	return cnt;
}

int
printf(const char *fmt, ...)
  801bdd:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(1, fmt, ap);
  801be0:	89 44 24 08          	mov    %eax,0x8(%esp)
  801be4:	8b 45 08             	mov    0x8(%ebp),%eax
  801be7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801beb:	c7 04 24 01 00 00 00 	movl   $0x1,(%esp)
  801bf2:	e8 67 ff ff ff       	call   801b5e <vfprintf>
	va_end(ap);

	return cnt;
}
  801bf7:	c9                   	leave  
  801bf8:	c3                   	ret    

00801bf9 <fprintf>:
	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
{
  801bf9:	55                   	push   %ebp
  801bfa:	89 e5                	mov    %esp,%ebp
  801bfc:	83 ec 18             	sub    $0x18,%esp

	return (b.result ? b.result : b.error);
}

int
fprintf(int fd, const char *fmt, ...)
  801bff:	8d 45 10             	lea    0x10(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vfprintf(fd, fmt, ap);
  801c02:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c06:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c09:	89 44 24 04          	mov    %eax,0x4(%esp)
  801c0d:	8b 45 08             	mov    0x8(%ebp),%eax
  801c10:	89 04 24             	mov    %eax,(%esp)
  801c13:	e8 46 ff ff ff       	call   801b5e <vfprintf>
	va_end(ap);

	return cnt;
}
  801c18:	c9                   	leave  
  801c19:	c3                   	ret    

00801c1a <putch>:
	}
}

static void
putch(int ch, void *thunk)
{
  801c1a:	55                   	push   %ebp
  801c1b:	89 e5                	mov    %esp,%ebp
  801c1d:	53                   	push   %ebx
  801c1e:	83 ec 04             	sub    $0x4,%esp
	struct printbuf *b = (struct printbuf *) thunk;
  801c21:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  801c24:	8b 43 04             	mov    0x4(%ebx),%eax
  801c27:	8b 55 08             	mov    0x8(%ebp),%edx
  801c2a:	88 54 03 10          	mov    %dl,0x10(%ebx,%eax,1)
  801c2e:	83 c0 01             	add    $0x1,%eax
  801c31:	89 43 04             	mov    %eax,0x4(%ebx)
	if (b->idx == 256) {
  801c34:	3d 00 01 00 00       	cmp    $0x100,%eax
  801c39:	75 0e                	jne    801c49 <putch+0x2f>
		writebuf(b);
  801c3b:	89 d8                	mov    %ebx,%eax
  801c3d:	e8 d6 fe ff ff       	call   801b18 <writebuf>
		b->idx = 0;
  801c42:	c7 43 04 00 00 00 00 	movl   $0x0,0x4(%ebx)
	}
}
  801c49:	83 c4 04             	add    $0x4,%esp
  801c4c:	5b                   	pop    %ebx
  801c4d:	5d                   	pop    %ebp
  801c4e:	c3                   	ret    
	...

00801c50 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  801c50:	55                   	push   %ebp
  801c51:	89 e5                	mov    %esp,%ebp
  801c53:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  801c56:	c7 44 24 04 c8 2e 80 	movl   $0x802ec8,0x4(%esp)
  801c5d:	00 
  801c5e:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c61:	89 04 24             	mov    %eax,(%esp)
  801c64:	e8 11 ed ff ff       	call   80097a <strcpy>
	return 0;
}
  801c69:	b8 00 00 00 00       	mov    $0x0,%eax
  801c6e:	c9                   	leave  
  801c6f:	c3                   	ret    

00801c70 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  801c70:	55                   	push   %ebp
  801c71:	89 e5                	mov    %esp,%ebp
  801c73:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  801c76:	8b 45 08             	mov    0x8(%ebp),%eax
  801c79:	8b 40 0c             	mov    0xc(%eax),%eax
  801c7c:	89 04 24             	mov    %eax,(%esp)
  801c7f:	e8 9d 02 00 00       	call   801f21 <nsipc_close>
}
  801c84:	c9                   	leave  
  801c85:	c3                   	ret    

00801c86 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  801c86:	55                   	push   %ebp
  801c87:	89 e5                	mov    %esp,%ebp
  801c89:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  801c8c:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801c93:	00 
  801c94:	8b 45 10             	mov    0x10(%ebp),%eax
  801c97:	89 44 24 08          	mov    %eax,0x8(%esp)
  801c9b:	8b 45 0c             	mov    0xc(%ebp),%eax
  801c9e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ca2:	8b 45 08             	mov    0x8(%ebp),%eax
  801ca5:	8b 40 0c             	mov    0xc(%eax),%eax
  801ca8:	89 04 24             	mov    %eax,(%esp)
  801cab:	e8 ad 02 00 00       	call   801f5d <nsipc_send>
}
  801cb0:	c9                   	leave  
  801cb1:	c3                   	ret    

00801cb2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  801cb2:	55                   	push   %ebp
  801cb3:	89 e5                	mov    %esp,%ebp
  801cb5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  801cb8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801cbf:	00 
  801cc0:	8b 45 10             	mov    0x10(%ebp),%eax
  801cc3:	89 44 24 08          	mov    %eax,0x8(%esp)
  801cc7:	8b 45 0c             	mov    0xc(%ebp),%eax
  801cca:	89 44 24 04          	mov    %eax,0x4(%esp)
  801cce:	8b 45 08             	mov    0x8(%ebp),%eax
  801cd1:	8b 40 0c             	mov    0xc(%eax),%eax
  801cd4:	89 04 24             	mov    %eax,(%esp)
  801cd7:	e8 f4 02 00 00       	call   801fd0 <nsipc_recv>
}
  801cdc:	c9                   	leave  
  801cdd:	c3                   	ret    

00801cde <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  801cde:	55                   	push   %ebp
  801cdf:	89 e5                	mov    %esp,%ebp
  801ce1:	56                   	push   %esi
  801ce2:	53                   	push   %ebx
  801ce3:	83 ec 20             	sub    $0x20,%esp
  801ce6:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801ce8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801ceb:	89 04 24             	mov    %eax,(%esp)
  801cee:	e8 38 f5 ff ff       	call   80122b <fd_alloc>
  801cf3:	89 c3                	mov    %eax,%ebx
  801cf5:	85 c0                	test   %eax,%eax
  801cf7:	78 21                	js     801d1a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  801cf9:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801d00:	00 
  801d01:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d04:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d08:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801d0f:	e8 c2 f3 ff ff       	call   8010d6 <sys_page_alloc>
  801d14:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801d16:	85 c0                	test   %eax,%eax
  801d18:	79 0a                	jns    801d24 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  801d1a:	89 34 24             	mov    %esi,(%esp)
  801d1d:	e8 ff 01 00 00       	call   801f21 <nsipc_close>
		return r;
  801d22:	eb 28                	jmp    801d4c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  801d24:	8b 15 20 60 80 00    	mov    0x806020,%edx
  801d2a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d2d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  801d2f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d32:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  801d39:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d3c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  801d3f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801d42:	89 04 24             	mov    %eax,(%esp)
  801d45:	e8 b6 f4 ff ff       	call   801200 <fd2num>
  801d4a:	89 c3                	mov    %eax,%ebx
}
  801d4c:	89 d8                	mov    %ebx,%eax
  801d4e:	83 c4 20             	add    $0x20,%esp
  801d51:	5b                   	pop    %ebx
  801d52:	5e                   	pop    %esi
  801d53:	5d                   	pop    %ebp
  801d54:	c3                   	ret    

00801d55 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  801d55:	55                   	push   %ebp
  801d56:	89 e5                	mov    %esp,%ebp
  801d58:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  801d5b:	8b 45 10             	mov    0x10(%ebp),%eax
  801d5e:	89 44 24 08          	mov    %eax,0x8(%esp)
  801d62:	8b 45 0c             	mov    0xc(%ebp),%eax
  801d65:	89 44 24 04          	mov    %eax,0x4(%esp)
  801d69:	8b 45 08             	mov    0x8(%ebp),%eax
  801d6c:	89 04 24             	mov    %eax,(%esp)
  801d6f:	e8 61 01 00 00       	call   801ed5 <nsipc_socket>
  801d74:	85 c0                	test   %eax,%eax
  801d76:	78 05                	js     801d7d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  801d78:	e8 61 ff ff ff       	call   801cde <alloc_sockfd>
}
  801d7d:	c9                   	leave  
  801d7e:	66 90                	xchg   %ax,%ax
  801d80:	c3                   	ret    

00801d81 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  801d81:	55                   	push   %ebp
  801d82:	89 e5                	mov    %esp,%ebp
  801d84:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  801d87:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801d8a:	89 54 24 04          	mov    %edx,0x4(%esp)
  801d8e:	89 04 24             	mov    %eax,(%esp)
  801d91:	e8 07 f5 ff ff       	call   80129d <fd_lookup>
  801d96:	85 c0                	test   %eax,%eax
  801d98:	78 15                	js     801daf <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  801d9a:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801d9d:	8b 0a                	mov    (%edx),%ecx
  801d9f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801da4:	3b 0d 20 60 80 00    	cmp    0x806020,%ecx
  801daa:	75 03                	jne    801daf <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  801dac:	8b 42 0c             	mov    0xc(%edx),%eax
}
  801daf:	c9                   	leave  
  801db0:	c3                   	ret    

00801db1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  801db1:	55                   	push   %ebp
  801db2:	89 e5                	mov    %esp,%ebp
  801db4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801db7:	8b 45 08             	mov    0x8(%ebp),%eax
  801dba:	e8 c2 ff ff ff       	call   801d81 <fd2sockid>
  801dbf:	85 c0                	test   %eax,%eax
  801dc1:	78 0f                	js     801dd2 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  801dc3:	8b 55 0c             	mov    0xc(%ebp),%edx
  801dc6:	89 54 24 04          	mov    %edx,0x4(%esp)
  801dca:	89 04 24             	mov    %eax,(%esp)
  801dcd:	e8 2d 01 00 00       	call   801eff <nsipc_listen>
}
  801dd2:	c9                   	leave  
  801dd3:	c3                   	ret    

00801dd4 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  801dd4:	55                   	push   %ebp
  801dd5:	89 e5                	mov    %esp,%ebp
  801dd7:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801dda:	8b 45 08             	mov    0x8(%ebp),%eax
  801ddd:	e8 9f ff ff ff       	call   801d81 <fd2sockid>
  801de2:	85 c0                	test   %eax,%eax
  801de4:	78 16                	js     801dfc <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  801de6:	8b 55 10             	mov    0x10(%ebp),%edx
  801de9:	89 54 24 08          	mov    %edx,0x8(%esp)
  801ded:	8b 55 0c             	mov    0xc(%ebp),%edx
  801df0:	89 54 24 04          	mov    %edx,0x4(%esp)
  801df4:	89 04 24             	mov    %eax,(%esp)
  801df7:	e8 54 02 00 00       	call   802050 <nsipc_connect>
}
  801dfc:	c9                   	leave  
  801dfd:	c3                   	ret    

00801dfe <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  801dfe:	55                   	push   %ebp
  801dff:	89 e5                	mov    %esp,%ebp
  801e01:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e04:	8b 45 08             	mov    0x8(%ebp),%eax
  801e07:	e8 75 ff ff ff       	call   801d81 <fd2sockid>
  801e0c:	85 c0                	test   %eax,%eax
  801e0e:	78 0f                	js     801e1f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  801e10:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e13:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e17:	89 04 24             	mov    %eax,(%esp)
  801e1a:	e8 1c 01 00 00       	call   801f3b <nsipc_shutdown>
}
  801e1f:	c9                   	leave  
  801e20:	c3                   	ret    

00801e21 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  801e21:	55                   	push   %ebp
  801e22:	89 e5                	mov    %esp,%ebp
  801e24:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e27:	8b 45 08             	mov    0x8(%ebp),%eax
  801e2a:	e8 52 ff ff ff       	call   801d81 <fd2sockid>
  801e2f:	85 c0                	test   %eax,%eax
  801e31:	78 16                	js     801e49 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  801e33:	8b 55 10             	mov    0x10(%ebp),%edx
  801e36:	89 54 24 08          	mov    %edx,0x8(%esp)
  801e3a:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e3d:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e41:	89 04 24             	mov    %eax,(%esp)
  801e44:	e8 46 02 00 00       	call   80208f <nsipc_bind>
}
  801e49:	c9                   	leave  
  801e4a:	c3                   	ret    

00801e4b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  801e4b:	55                   	push   %ebp
  801e4c:	89 e5                	mov    %esp,%ebp
  801e4e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801e51:	8b 45 08             	mov    0x8(%ebp),%eax
  801e54:	e8 28 ff ff ff       	call   801d81 <fd2sockid>
  801e59:	85 c0                	test   %eax,%eax
  801e5b:	78 1f                	js     801e7c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  801e5d:	8b 55 10             	mov    0x10(%ebp),%edx
  801e60:	89 54 24 08          	mov    %edx,0x8(%esp)
  801e64:	8b 55 0c             	mov    0xc(%ebp),%edx
  801e67:	89 54 24 04          	mov    %edx,0x4(%esp)
  801e6b:	89 04 24             	mov    %eax,(%esp)
  801e6e:	e8 5b 02 00 00       	call   8020ce <nsipc_accept>
  801e73:	85 c0                	test   %eax,%eax
  801e75:	78 05                	js     801e7c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  801e77:	e8 62 fe ff ff       	call   801cde <alloc_sockfd>
}
  801e7c:	c9                   	leave  
  801e7d:	8d 76 00             	lea    0x0(%esi),%esi
  801e80:	c3                   	ret    
	...

00801e90 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  801e90:	55                   	push   %ebp
  801e91:	89 e5                	mov    %esp,%ebp
  801e93:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  801e96:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  801e9c:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801ea3:	00 
  801ea4:	c7 44 24 08 00 50 80 	movl   $0x805000,0x8(%esp)
  801eab:	00 
  801eac:	89 44 24 04          	mov    %eax,0x4(%esp)
  801eb0:	89 14 24             	mov    %edx,(%esp)
  801eb3:	e8 18 08 00 00       	call   8026d0 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  801eb8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801ebf:	00 
  801ec0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801ec7:	00 
  801ec8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801ecb:	89 04 24             	mov    %eax,(%esp)
  801ece:	e8 6f 08 00 00       	call   802742 <ipc_recv>
    return r;
}
  801ed3:	c9                   	leave  
  801ed4:	c3                   	ret    

00801ed5 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  801ed5:	55                   	push   %ebp
  801ed6:	89 e5                	mov    %esp,%ebp
  801ed8:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  801edb:	8b 45 08             	mov    0x8(%ebp),%eax
  801ede:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.socket.req_type = type;
  801ee3:	8b 45 0c             	mov    0xc(%ebp),%eax
  801ee6:	a3 04 50 80 00       	mov    %eax,0x805004
	nsipcbuf.socket.req_protocol = protocol;
  801eeb:	8b 45 10             	mov    0x10(%ebp),%eax
  801eee:	a3 08 50 80 00       	mov    %eax,0x805008
	return nsipc(NSREQ_SOCKET);
  801ef3:	b8 09 00 00 00       	mov    $0x9,%eax
  801ef8:	e8 93 ff ff ff       	call   801e90 <nsipc>
}
  801efd:	c9                   	leave  
  801efe:	c3                   	ret    

00801eff <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  801eff:	55                   	push   %ebp
  801f00:	89 e5                	mov    %esp,%ebp
  801f02:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  801f05:	8b 45 08             	mov    0x8(%ebp),%eax
  801f08:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.listen.req_backlog = backlog;
  801f0d:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f10:	a3 04 50 80 00       	mov    %eax,0x805004
	return nsipc(NSREQ_LISTEN);
  801f15:	b8 06 00 00 00       	mov    $0x6,%eax
  801f1a:	e8 71 ff ff ff       	call   801e90 <nsipc>
}
  801f1f:	c9                   	leave  
  801f20:	c3                   	ret    

00801f21 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  801f21:	55                   	push   %ebp
  801f22:	89 e5                	mov    %esp,%ebp
  801f24:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  801f27:	8b 45 08             	mov    0x8(%ebp),%eax
  801f2a:	a3 00 50 80 00       	mov    %eax,0x805000
	return nsipc(NSREQ_CLOSE);
  801f2f:	b8 04 00 00 00       	mov    $0x4,%eax
  801f34:	e8 57 ff ff ff       	call   801e90 <nsipc>
}
  801f39:	c9                   	leave  
  801f3a:	c3                   	ret    

00801f3b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  801f3b:	55                   	push   %ebp
  801f3c:	89 e5                	mov    %esp,%ebp
  801f3e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  801f41:	8b 45 08             	mov    0x8(%ebp),%eax
  801f44:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.shutdown.req_how = how;
  801f49:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f4c:	a3 04 50 80 00       	mov    %eax,0x805004
	return nsipc(NSREQ_SHUTDOWN);
  801f51:	b8 03 00 00 00       	mov    $0x3,%eax
  801f56:	e8 35 ff ff ff       	call   801e90 <nsipc>
}
  801f5b:	c9                   	leave  
  801f5c:	c3                   	ret    

00801f5d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  801f5d:	55                   	push   %ebp
  801f5e:	89 e5                	mov    %esp,%ebp
  801f60:	53                   	push   %ebx
  801f61:	83 ec 14             	sub    $0x14,%esp
  801f64:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  801f67:	8b 45 08             	mov    0x8(%ebp),%eax
  801f6a:	a3 00 50 80 00       	mov    %eax,0x805000
	assert(size < 1600);
  801f6f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  801f75:	7e 24                	jle    801f9b <nsipc_send+0x3e>
  801f77:	c7 44 24 0c d4 2e 80 	movl   $0x802ed4,0xc(%esp)
  801f7e:	00 
  801f7f:	c7 44 24 08 e0 2e 80 	movl   $0x802ee0,0x8(%esp)
  801f86:	00 
  801f87:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  801f8e:	00 
  801f8f:	c7 04 24 f5 2e 80 00 	movl   $0x802ef5,(%esp)
  801f96:	e8 45 e2 ff ff       	call   8001e0 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  801f9b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801f9f:	8b 45 0c             	mov    0xc(%ebp),%eax
  801fa2:	89 44 24 04          	mov    %eax,0x4(%esp)
  801fa6:	c7 04 24 0c 50 80 00 	movl   $0x80500c,(%esp)
  801fad:	e8 83 eb ff ff       	call   800b35 <memmove>
	nsipcbuf.send.req_size = size;
  801fb2:	89 1d 04 50 80 00    	mov    %ebx,0x805004
	nsipcbuf.send.req_flags = flags;
  801fb8:	8b 45 14             	mov    0x14(%ebp),%eax
  801fbb:	a3 08 50 80 00       	mov    %eax,0x805008
	return nsipc(NSREQ_SEND);
  801fc0:	b8 08 00 00 00       	mov    $0x8,%eax
  801fc5:	e8 c6 fe ff ff       	call   801e90 <nsipc>
}
  801fca:	83 c4 14             	add    $0x14,%esp
  801fcd:	5b                   	pop    %ebx
  801fce:	5d                   	pop    %ebp
  801fcf:	c3                   	ret    

00801fd0 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  801fd0:	55                   	push   %ebp
  801fd1:	89 e5                	mov    %esp,%ebp
  801fd3:	56                   	push   %esi
  801fd4:	53                   	push   %ebx
  801fd5:	83 ec 10             	sub    $0x10,%esp
  801fd8:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  801fdb:	8b 45 08             	mov    0x8(%ebp),%eax
  801fde:	a3 00 50 80 00       	mov    %eax,0x805000
	nsipcbuf.recv.req_len = len;
  801fe3:	89 35 04 50 80 00    	mov    %esi,0x805004
	nsipcbuf.recv.req_flags = flags;
  801fe9:	8b 45 14             	mov    0x14(%ebp),%eax
  801fec:	a3 08 50 80 00       	mov    %eax,0x805008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  801ff1:	b8 07 00 00 00       	mov    $0x7,%eax
  801ff6:	e8 95 fe ff ff       	call   801e90 <nsipc>
  801ffb:	89 c3                	mov    %eax,%ebx
  801ffd:	85 c0                	test   %eax,%eax
  801fff:	78 46                	js     802047 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  802001:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  802006:	7f 04                	jg     80200c <nsipc_recv+0x3c>
  802008:	39 c6                	cmp    %eax,%esi
  80200a:	7d 24                	jge    802030 <nsipc_recv+0x60>
  80200c:	c7 44 24 0c 01 2f 80 	movl   $0x802f01,0xc(%esp)
  802013:	00 
  802014:	c7 44 24 08 e0 2e 80 	movl   $0x802ee0,0x8(%esp)
  80201b:	00 
  80201c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802023:	00 
  802024:	c7 04 24 f5 2e 80 00 	movl   $0x802ef5,(%esp)
  80202b:	e8 b0 e1 ff ff       	call   8001e0 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802030:	89 44 24 08          	mov    %eax,0x8(%esp)
  802034:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  80203b:	00 
  80203c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80203f:	89 04 24             	mov    %eax,(%esp)
  802042:	e8 ee ea ff ff       	call   800b35 <memmove>
	}

	return r;
}
  802047:	89 d8                	mov    %ebx,%eax
  802049:	83 c4 10             	add    $0x10,%esp
  80204c:	5b                   	pop    %ebx
  80204d:	5e                   	pop    %esi
  80204e:	5d                   	pop    %ebp
  80204f:	c3                   	ret    

00802050 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802050:	55                   	push   %ebp
  802051:	89 e5                	mov    %esp,%ebp
  802053:	53                   	push   %ebx
  802054:	83 ec 14             	sub    $0x14,%esp
  802057:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80205a:	8b 45 08             	mov    0x8(%ebp),%eax
  80205d:	a3 00 50 80 00       	mov    %eax,0x805000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802062:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802066:	8b 45 0c             	mov    0xc(%ebp),%eax
  802069:	89 44 24 04          	mov    %eax,0x4(%esp)
  80206d:	c7 04 24 04 50 80 00 	movl   $0x805004,(%esp)
  802074:	e8 bc ea ff ff       	call   800b35 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  802079:	89 1d 14 50 80 00    	mov    %ebx,0x805014
	return nsipc(NSREQ_CONNECT);
  80207f:	b8 05 00 00 00       	mov    $0x5,%eax
  802084:	e8 07 fe ff ff       	call   801e90 <nsipc>
}
  802089:	83 c4 14             	add    $0x14,%esp
  80208c:	5b                   	pop    %ebx
  80208d:	5d                   	pop    %ebp
  80208e:	c3                   	ret    

0080208f <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  80208f:	55                   	push   %ebp
  802090:	89 e5                	mov    %esp,%ebp
  802092:	53                   	push   %ebx
  802093:	83 ec 14             	sub    $0x14,%esp
  802096:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  802099:	8b 45 08             	mov    0x8(%ebp),%eax
  80209c:	a3 00 50 80 00       	mov    %eax,0x805000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  8020a1:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8020a5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020a8:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020ac:	c7 04 24 04 50 80 00 	movl   $0x805004,(%esp)
  8020b3:	e8 7d ea ff ff       	call   800b35 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  8020b8:	89 1d 14 50 80 00    	mov    %ebx,0x805014
	return nsipc(NSREQ_BIND);
  8020be:	b8 02 00 00 00       	mov    $0x2,%eax
  8020c3:	e8 c8 fd ff ff       	call   801e90 <nsipc>
}
  8020c8:	83 c4 14             	add    $0x14,%esp
  8020cb:	5b                   	pop    %ebx
  8020cc:	5d                   	pop    %ebp
  8020cd:	c3                   	ret    

008020ce <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8020ce:	55                   	push   %ebp
  8020cf:	89 e5                	mov    %esp,%ebp
  8020d1:	83 ec 18             	sub    $0x18,%esp
  8020d4:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8020d7:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  8020da:	8b 45 08             	mov    0x8(%ebp),%eax
  8020dd:	a3 00 50 80 00       	mov    %eax,0x805000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  8020e2:	b8 01 00 00 00       	mov    $0x1,%eax
  8020e7:	e8 a4 fd ff ff       	call   801e90 <nsipc>
  8020ec:	89 c3                	mov    %eax,%ebx
  8020ee:	85 c0                	test   %eax,%eax
  8020f0:	78 25                	js     802117 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  8020f2:	be 10 50 80 00       	mov    $0x805010,%esi
  8020f7:	8b 06                	mov    (%esi),%eax
  8020f9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8020fd:	c7 44 24 04 00 50 80 	movl   $0x805000,0x4(%esp)
  802104:	00 
  802105:	8b 45 0c             	mov    0xc(%ebp),%eax
  802108:	89 04 24             	mov    %eax,(%esp)
  80210b:	e8 25 ea ff ff       	call   800b35 <memmove>
		*addrlen = ret->ret_addrlen;
  802110:	8b 16                	mov    (%esi),%edx
  802112:	8b 45 10             	mov    0x10(%ebp),%eax
  802115:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802117:	89 d8                	mov    %ebx,%eax
  802119:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80211c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80211f:	89 ec                	mov    %ebp,%esp
  802121:	5d                   	pop    %ebp
  802122:	c3                   	ret    
	...

00802130 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802130:	55                   	push   %ebp
  802131:	89 e5                	mov    %esp,%ebp
  802133:	83 ec 18             	sub    $0x18,%esp
  802136:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802139:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80213c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80213f:	8b 45 08             	mov    0x8(%ebp),%eax
  802142:	89 04 24             	mov    %eax,(%esp)
  802145:	e8 c6 f0 ff ff       	call   801210 <fd2data>
  80214a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80214c:	c7 44 24 04 16 2f 80 	movl   $0x802f16,0x4(%esp)
  802153:	00 
  802154:	89 34 24             	mov    %esi,(%esp)
  802157:	e8 1e e8 ff ff       	call   80097a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80215c:	8b 43 04             	mov    0x4(%ebx),%eax
  80215f:	2b 03                	sub    (%ebx),%eax
  802161:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802167:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80216e:	00 00 00 
	stat->st_dev = &devpipe;
  802171:	c7 86 88 00 00 00 3c 	movl   $0x80603c,0x88(%esi)
  802178:	60 80 00 
	return 0;
}
  80217b:	b8 00 00 00 00       	mov    $0x0,%eax
  802180:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802183:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802186:	89 ec                	mov    %ebp,%esp
  802188:	5d                   	pop    %ebp
  802189:	c3                   	ret    

0080218a <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  80218a:	55                   	push   %ebp
  80218b:	89 e5                	mov    %esp,%ebp
  80218d:	53                   	push   %ebx
  80218e:	83 ec 14             	sub    $0x14,%esp
  802191:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802194:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802198:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80219f:	e8 76 ee ff ff       	call   80101a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  8021a4:	89 1c 24             	mov    %ebx,(%esp)
  8021a7:	e8 64 f0 ff ff       	call   801210 <fd2data>
  8021ac:	89 44 24 04          	mov    %eax,0x4(%esp)
  8021b0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8021b7:	e8 5e ee ff ff       	call   80101a <sys_page_unmap>
}
  8021bc:	83 c4 14             	add    $0x14,%esp
  8021bf:	5b                   	pop    %ebx
  8021c0:	5d                   	pop    %ebp
  8021c1:	c3                   	ret    

008021c2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  8021c2:	55                   	push   %ebp
  8021c3:	89 e5                	mov    %esp,%ebp
  8021c5:	57                   	push   %edi
  8021c6:	56                   	push   %esi
  8021c7:	53                   	push   %ebx
  8021c8:	83 ec 2c             	sub    $0x2c,%esp
  8021cb:	89 c7                	mov    %eax,%edi
  8021cd:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  8021d0:	a1 80 80 80 00       	mov    0x808080,%eax
  8021d5:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  8021d8:	89 3c 24             	mov    %edi,(%esp)
  8021db:	e8 b4 05 00 00       	call   802794 <pageref>
  8021e0:	89 c6                	mov    %eax,%esi
  8021e2:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8021e5:	89 04 24             	mov    %eax,(%esp)
  8021e8:	e8 a7 05 00 00       	call   802794 <pageref>
  8021ed:	39 c6                	cmp    %eax,%esi
  8021ef:	0f 94 c0             	sete   %al
  8021f2:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  8021f5:	8b 15 80 80 80 00    	mov    0x808080,%edx
  8021fb:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  8021fe:	39 cb                	cmp    %ecx,%ebx
  802200:	75 08                	jne    80220a <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  802202:	83 c4 2c             	add    $0x2c,%esp
  802205:	5b                   	pop    %ebx
  802206:	5e                   	pop    %esi
  802207:	5f                   	pop    %edi
  802208:	5d                   	pop    %ebp
  802209:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  80220a:	83 f8 01             	cmp    $0x1,%eax
  80220d:	75 c1                	jne    8021d0 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  80220f:	8b 52 58             	mov    0x58(%edx),%edx
  802212:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802216:	89 54 24 08          	mov    %edx,0x8(%esp)
  80221a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80221e:	c7 04 24 1d 2f 80 00 	movl   $0x802f1d,(%esp)
  802225:	e8 7b e0 ff ff       	call   8002a5 <cprintf>
  80222a:	eb a4                	jmp    8021d0 <_pipeisclosed+0xe>

0080222c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80222c:	55                   	push   %ebp
  80222d:	89 e5                	mov    %esp,%ebp
  80222f:	57                   	push   %edi
  802230:	56                   	push   %esi
  802231:	53                   	push   %ebx
  802232:	83 ec 1c             	sub    $0x1c,%esp
  802235:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802238:	89 34 24             	mov    %esi,(%esp)
  80223b:	e8 d0 ef ff ff       	call   801210 <fd2data>
  802240:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802242:	bf 00 00 00 00       	mov    $0x0,%edi
  802247:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80224b:	75 54                	jne    8022a1 <devpipe_write+0x75>
  80224d:	eb 60                	jmp    8022af <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80224f:	89 da                	mov    %ebx,%edx
  802251:	89 f0                	mov    %esi,%eax
  802253:	e8 6a ff ff ff       	call   8021c2 <_pipeisclosed>
  802258:	85 c0                	test   %eax,%eax
  80225a:	74 07                	je     802263 <devpipe_write+0x37>
  80225c:	b8 00 00 00 00       	mov    $0x0,%eax
  802261:	eb 53                	jmp    8022b6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802263:	90                   	nop
  802264:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802268:	e8 c8 ee ff ff       	call   801135 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  80226d:	8b 43 04             	mov    0x4(%ebx),%eax
  802270:	8b 13                	mov    (%ebx),%edx
  802272:	83 c2 20             	add    $0x20,%edx
  802275:	39 d0                	cmp    %edx,%eax
  802277:	73 d6                	jae    80224f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802279:	89 c2                	mov    %eax,%edx
  80227b:	c1 fa 1f             	sar    $0x1f,%edx
  80227e:	c1 ea 1b             	shr    $0x1b,%edx
  802281:	01 d0                	add    %edx,%eax
  802283:	83 e0 1f             	and    $0x1f,%eax
  802286:	29 d0                	sub    %edx,%eax
  802288:	89 c2                	mov    %eax,%edx
  80228a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80228d:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802291:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802295:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802299:	83 c7 01             	add    $0x1,%edi
  80229c:	39 7d 10             	cmp    %edi,0x10(%ebp)
  80229f:	76 13                	jbe    8022b4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  8022a1:	8b 43 04             	mov    0x4(%ebx),%eax
  8022a4:	8b 13                	mov    (%ebx),%edx
  8022a6:	83 c2 20             	add    $0x20,%edx
  8022a9:	39 d0                	cmp    %edx,%eax
  8022ab:	73 a2                	jae    80224f <devpipe_write+0x23>
  8022ad:	eb ca                	jmp    802279 <devpipe_write+0x4d>
  8022af:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  8022b4:	89 f8                	mov    %edi,%eax
}
  8022b6:	83 c4 1c             	add    $0x1c,%esp
  8022b9:	5b                   	pop    %ebx
  8022ba:	5e                   	pop    %esi
  8022bb:	5f                   	pop    %edi
  8022bc:	5d                   	pop    %ebp
  8022bd:	c3                   	ret    

008022be <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  8022be:	55                   	push   %ebp
  8022bf:	89 e5                	mov    %esp,%ebp
  8022c1:	83 ec 28             	sub    $0x28,%esp
  8022c4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8022c7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8022ca:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8022cd:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  8022d0:	89 3c 24             	mov    %edi,(%esp)
  8022d3:	e8 38 ef ff ff       	call   801210 <fd2data>
  8022d8:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8022da:	be 00 00 00 00       	mov    $0x0,%esi
  8022df:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8022e3:	75 4c                	jne    802331 <devpipe_read+0x73>
  8022e5:	eb 5b                	jmp    802342 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  8022e7:	89 f0                	mov    %esi,%eax
  8022e9:	eb 5e                	jmp    802349 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  8022eb:	89 da                	mov    %ebx,%edx
  8022ed:	89 f8                	mov    %edi,%eax
  8022ef:	90                   	nop
  8022f0:	e8 cd fe ff ff       	call   8021c2 <_pipeisclosed>
  8022f5:	85 c0                	test   %eax,%eax
  8022f7:	74 07                	je     802300 <devpipe_read+0x42>
  8022f9:	b8 00 00 00 00       	mov    $0x0,%eax
  8022fe:	eb 49                	jmp    802349 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  802300:	e8 30 ee ff ff       	call   801135 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  802305:	8b 03                	mov    (%ebx),%eax
  802307:	3b 43 04             	cmp    0x4(%ebx),%eax
  80230a:	74 df                	je     8022eb <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  80230c:	89 c2                	mov    %eax,%edx
  80230e:	c1 fa 1f             	sar    $0x1f,%edx
  802311:	c1 ea 1b             	shr    $0x1b,%edx
  802314:	01 d0                	add    %edx,%eax
  802316:	83 e0 1f             	and    $0x1f,%eax
  802319:	29 d0                	sub    %edx,%eax
  80231b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802320:	8b 55 0c             	mov    0xc(%ebp),%edx
  802323:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802326:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802329:	83 c6 01             	add    $0x1,%esi
  80232c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80232f:	76 16                	jbe    802347 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802331:	8b 03                	mov    (%ebx),%eax
  802333:	3b 43 04             	cmp    0x4(%ebx),%eax
  802336:	75 d4                	jne    80230c <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802338:	85 f6                	test   %esi,%esi
  80233a:	75 ab                	jne    8022e7 <devpipe_read+0x29>
  80233c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802340:	eb a9                	jmp    8022eb <devpipe_read+0x2d>
  802342:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802347:	89 f0                	mov    %esi,%eax
}
  802349:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80234c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80234f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802352:	89 ec                	mov    %ebp,%esp
  802354:	5d                   	pop    %ebp
  802355:	c3                   	ret    

00802356 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802356:	55                   	push   %ebp
  802357:	89 e5                	mov    %esp,%ebp
  802359:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80235c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80235f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802363:	8b 45 08             	mov    0x8(%ebp),%eax
  802366:	89 04 24             	mov    %eax,(%esp)
  802369:	e8 2f ef ff ff       	call   80129d <fd_lookup>
  80236e:	85 c0                	test   %eax,%eax
  802370:	78 15                	js     802387 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802372:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802375:	89 04 24             	mov    %eax,(%esp)
  802378:	e8 93 ee ff ff       	call   801210 <fd2data>
	return _pipeisclosed(fd, p);
  80237d:	89 c2                	mov    %eax,%edx
  80237f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802382:	e8 3b fe ff ff       	call   8021c2 <_pipeisclosed>
}
  802387:	c9                   	leave  
  802388:	c3                   	ret    

00802389 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  802389:	55                   	push   %ebp
  80238a:	89 e5                	mov    %esp,%ebp
  80238c:	83 ec 48             	sub    $0x48,%esp
  80238f:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802392:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802395:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802398:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80239b:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80239e:	89 04 24             	mov    %eax,(%esp)
  8023a1:	e8 85 ee ff ff       	call   80122b <fd_alloc>
  8023a6:	89 c3                	mov    %eax,%ebx
  8023a8:	85 c0                	test   %eax,%eax
  8023aa:	0f 88 42 01 00 00    	js     8024f2 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8023b0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8023b7:	00 
  8023b8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8023bb:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023bf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8023c6:	e8 0b ed ff ff       	call   8010d6 <sys_page_alloc>
  8023cb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8023cd:	85 c0                	test   %eax,%eax
  8023cf:	0f 88 1d 01 00 00    	js     8024f2 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8023d5:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8023d8:	89 04 24             	mov    %eax,(%esp)
  8023db:	e8 4b ee ff ff       	call   80122b <fd_alloc>
  8023e0:	89 c3                	mov    %eax,%ebx
  8023e2:	85 c0                	test   %eax,%eax
  8023e4:	0f 88 f5 00 00 00    	js     8024df <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8023ea:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8023f1:	00 
  8023f2:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8023f5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023f9:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802400:	e8 d1 ec ff ff       	call   8010d6 <sys_page_alloc>
  802405:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  802407:	85 c0                	test   %eax,%eax
  802409:	0f 88 d0 00 00 00    	js     8024df <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  80240f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802412:	89 04 24             	mov    %eax,(%esp)
  802415:	e8 f6 ed ff ff       	call   801210 <fd2data>
  80241a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80241c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802423:	00 
  802424:	89 44 24 04          	mov    %eax,0x4(%esp)
  802428:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80242f:	e8 a2 ec ff ff       	call   8010d6 <sys_page_alloc>
  802434:	89 c3                	mov    %eax,%ebx
  802436:	85 c0                	test   %eax,%eax
  802438:	0f 88 8e 00 00 00    	js     8024cc <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80243e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802441:	89 04 24             	mov    %eax,(%esp)
  802444:	e8 c7 ed ff ff       	call   801210 <fd2data>
  802449:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802450:	00 
  802451:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802455:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80245c:	00 
  80245d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802461:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802468:	e8 0b ec ff ff       	call   801078 <sys_page_map>
  80246d:	89 c3                	mov    %eax,%ebx
  80246f:	85 c0                	test   %eax,%eax
  802471:	78 49                	js     8024bc <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802473:	b8 3c 60 80 00       	mov    $0x80603c,%eax
  802478:	8b 08                	mov    (%eax),%ecx
  80247a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80247d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  80247f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802482:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  802489:	8b 10                	mov    (%eax),%edx
  80248b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80248e:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802490:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802493:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  80249a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80249d:	89 04 24             	mov    %eax,(%esp)
  8024a0:	e8 5b ed ff ff       	call   801200 <fd2num>
  8024a5:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  8024a7:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024aa:	89 04 24             	mov    %eax,(%esp)
  8024ad:	e8 4e ed ff ff       	call   801200 <fd2num>
  8024b2:	89 47 04             	mov    %eax,0x4(%edi)
  8024b5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  8024ba:	eb 36                	jmp    8024f2 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  8024bc:	89 74 24 04          	mov    %esi,0x4(%esp)
  8024c0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8024c7:	e8 4e eb ff ff       	call   80101a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  8024cc:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8024cf:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024d3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8024da:	e8 3b eb ff ff       	call   80101a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  8024df:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8024e2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8024e6:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8024ed:	e8 28 eb ff ff       	call   80101a <sys_page_unmap>
    err:
	return r;
}
  8024f2:	89 d8                	mov    %ebx,%eax
  8024f4:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8024f7:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8024fa:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8024fd:	89 ec                	mov    %ebp,%esp
  8024ff:	5d                   	pop    %ebp
  802500:	c3                   	ret    
	...

00802510 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802510:	55                   	push   %ebp
  802511:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802513:	b8 00 00 00 00       	mov    $0x0,%eax
  802518:	5d                   	pop    %ebp
  802519:	c3                   	ret    

0080251a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80251a:	55                   	push   %ebp
  80251b:	89 e5                	mov    %esp,%ebp
  80251d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802520:	c7 44 24 04 35 2f 80 	movl   $0x802f35,0x4(%esp)
  802527:	00 
  802528:	8b 45 0c             	mov    0xc(%ebp),%eax
  80252b:	89 04 24             	mov    %eax,(%esp)
  80252e:	e8 47 e4 ff ff       	call   80097a <strcpy>
	return 0;
}
  802533:	b8 00 00 00 00       	mov    $0x0,%eax
  802538:	c9                   	leave  
  802539:	c3                   	ret    

0080253a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80253a:	55                   	push   %ebp
  80253b:	89 e5                	mov    %esp,%ebp
  80253d:	57                   	push   %edi
  80253e:	56                   	push   %esi
  80253f:	53                   	push   %ebx
  802540:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802546:	b8 00 00 00 00       	mov    $0x0,%eax
  80254b:	be 00 00 00 00       	mov    $0x0,%esi
  802550:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802554:	74 41                	je     802597 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802556:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80255c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80255f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802561:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802567:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80256c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80256f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802573:	03 45 0c             	add    0xc(%ebp),%eax
  802576:	89 44 24 04          	mov    %eax,0x4(%esp)
  80257a:	89 3c 24             	mov    %edi,(%esp)
  80257d:	e8 b3 e5 ff ff       	call   800b35 <memmove>
		sys_cputs(buf, m);
  802582:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802586:	89 3c 24             	mov    %edi,(%esp)
  802589:	e8 e2 e7 ff ff       	call   800d70 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  80258e:	01 de                	add    %ebx,%esi
  802590:	89 f0                	mov    %esi,%eax
  802592:	3b 75 10             	cmp    0x10(%ebp),%esi
  802595:	72 c5                	jb     80255c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802597:	89 f0                	mov    %esi,%eax
  802599:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  80259f:	5b                   	pop    %ebx
  8025a0:	5e                   	pop    %esi
  8025a1:	5f                   	pop    %edi
  8025a2:	5d                   	pop    %ebp
  8025a3:	c3                   	ret    

008025a4 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  8025a4:	55                   	push   %ebp
  8025a5:	89 e5                	mov    %esp,%ebp
  8025a7:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  8025aa:	8b 45 08             	mov    0x8(%ebp),%eax
  8025ad:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  8025b0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8025b7:	00 
  8025b8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8025bb:	89 04 24             	mov    %eax,(%esp)
  8025be:	e8 ad e7 ff ff       	call   800d70 <sys_cputs>
}
  8025c3:	c9                   	leave  
  8025c4:	c3                   	ret    

008025c5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  8025c5:	55                   	push   %ebp
  8025c6:	89 e5                	mov    %esp,%ebp
  8025c8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  8025cb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8025cf:	75 07                	jne    8025d8 <devcons_read+0x13>
  8025d1:	eb 2d                	jmp    802600 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8025d3:	e8 5d eb ff ff       	call   801135 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8025d8:	90                   	nop
  8025d9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8025e0:	e8 57 e7 ff ff       	call   800d3c <sys_cgetc>
  8025e5:	85 c0                	test   %eax,%eax
  8025e7:	74 ea                	je     8025d3 <devcons_read+0xe>
  8025e9:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  8025eb:	85 c0                	test   %eax,%eax
  8025ed:	78 16                	js     802605 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  8025ef:	83 f8 04             	cmp    $0x4,%eax
  8025f2:	74 0c                	je     802600 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  8025f4:	8b 45 0c             	mov    0xc(%ebp),%eax
  8025f7:	88 10                	mov    %dl,(%eax)
  8025f9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  8025fe:	eb 05                	jmp    802605 <devcons_read+0x40>
  802600:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802605:	c9                   	leave  
  802606:	c3                   	ret    

00802607 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  802607:	55                   	push   %ebp
  802608:	89 e5                	mov    %esp,%ebp
  80260a:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  80260d:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802610:	89 04 24             	mov    %eax,(%esp)
  802613:	e8 13 ec ff ff       	call   80122b <fd_alloc>
  802618:	85 c0                	test   %eax,%eax
  80261a:	78 3f                	js     80265b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  80261c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802623:	00 
  802624:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802627:	89 44 24 04          	mov    %eax,0x4(%esp)
  80262b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802632:	e8 9f ea ff ff       	call   8010d6 <sys_page_alloc>
  802637:	85 c0                	test   %eax,%eax
  802639:	78 20                	js     80265b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  80263b:	8b 15 58 60 80 00    	mov    0x806058,%edx
  802641:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802644:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802646:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802649:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802650:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802653:	89 04 24             	mov    %eax,(%esp)
  802656:	e8 a5 eb ff ff       	call   801200 <fd2num>
}
  80265b:	c9                   	leave  
  80265c:	c3                   	ret    

0080265d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80265d:	55                   	push   %ebp
  80265e:	89 e5                	mov    %esp,%ebp
  802660:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802663:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802666:	89 44 24 04          	mov    %eax,0x4(%esp)
  80266a:	8b 45 08             	mov    0x8(%ebp),%eax
  80266d:	89 04 24             	mov    %eax,(%esp)
  802670:	e8 28 ec ff ff       	call   80129d <fd_lookup>
  802675:	85 c0                	test   %eax,%eax
  802677:	78 11                	js     80268a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802679:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80267c:	8b 00                	mov    (%eax),%eax
  80267e:	3b 05 58 60 80 00    	cmp    0x806058,%eax
  802684:	0f 94 c0             	sete   %al
  802687:	0f b6 c0             	movzbl %al,%eax
}
  80268a:	c9                   	leave  
  80268b:	c3                   	ret    

0080268c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  80268c:	55                   	push   %ebp
  80268d:	89 e5                	mov    %esp,%ebp
  80268f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802692:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802699:	00 
  80269a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80269d:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026a1:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026a8:	e8 56 ee ff ff       	call   801503 <read>
	if (r < 0)
  8026ad:	85 c0                	test   %eax,%eax
  8026af:	78 0f                	js     8026c0 <getchar+0x34>
		return r;
	if (r < 1)
  8026b1:	85 c0                	test   %eax,%eax
  8026b3:	7f 07                	jg     8026bc <getchar+0x30>
  8026b5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  8026ba:	eb 04                	jmp    8026c0 <getchar+0x34>
		return -E_EOF;
	return c;
  8026bc:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8026c0:	c9                   	leave  
  8026c1:	c3                   	ret    
	...

008026d0 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  8026d0:	55                   	push   %ebp
  8026d1:	89 e5                	mov    %esp,%ebp
  8026d3:	57                   	push   %edi
  8026d4:	56                   	push   %esi
  8026d5:	53                   	push   %ebx
  8026d6:	83 ec 2c             	sub    $0x2c,%esp
  8026d9:	8b 75 08             	mov    0x8(%ebp),%esi
  8026dc:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8026df:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  8026e2:	85 db                	test   %ebx,%ebx
  8026e4:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  8026e9:	0f 45 c3             	cmovne %ebx,%eax
  8026ec:	8b 55 14             	mov    0x14(%ebp),%edx
  8026ef:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8026f3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8026f7:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8026fb:	89 34 24             	mov    %esi,(%esp)
  8026fe:	e8 9d e7 ff ff       	call   800ea0 <sys_ipc_try_send>
  802703:	83 f8 f9             	cmp    $0xfffffff9,%eax
  802706:	75 0a                	jne    802712 <ipc_send+0x42>
      sys_yield();
  802708:	e8 28 ea ff ff       	call   801135 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  80270d:	8d 76 00             	lea    0x0(%esi),%esi
  802710:	eb d0                	jmp    8026e2 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  802712:	85 c0                	test   %eax,%eax
  802714:	79 24                	jns    80273a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  802716:	89 44 24 10          	mov    %eax,0x10(%esp)
  80271a:	89 74 24 0c          	mov    %esi,0xc(%esp)
  80271e:	c7 44 24 08 44 2f 80 	movl   $0x802f44,0x8(%esp)
  802725:	00 
  802726:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  80272d:	00 
  80272e:	c7 04 24 68 2f 80 00 	movl   $0x802f68,(%esp)
  802735:	e8 a6 da ff ff       	call   8001e0 <_panic>
    else
      return;
  }
}
  80273a:	83 c4 2c             	add    $0x2c,%esp
  80273d:	5b                   	pop    %ebx
  80273e:	5e                   	pop    %esi
  80273f:	5f                   	pop    %edi
  802740:	5d                   	pop    %ebp
  802741:	c3                   	ret    

00802742 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802742:	55                   	push   %ebp
  802743:	89 e5                	mov    %esp,%ebp
  802745:	56                   	push   %esi
  802746:	53                   	push   %ebx
  802747:	83 ec 10             	sub    $0x10,%esp
  80274a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80274d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802750:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802753:	85 c0                	test   %eax,%eax
  802755:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  80275a:	0f 44 c2             	cmove  %edx,%eax
  80275d:	89 04 24             	mov    %eax,(%esp)
  802760:	e8 de e6 ff ff       	call   800e43 <sys_ipc_recv>
  802765:	85 c0                	test   %eax,%eax
  802767:	78 24                	js     80278d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802769:	85 db                	test   %ebx,%ebx
  80276b:	74 0a                	je     802777 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  80276d:	a1 80 80 80 00       	mov    0x808080,%eax
  802772:	8b 40 74             	mov    0x74(%eax),%eax
  802775:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802777:	85 f6                	test   %esi,%esi
  802779:	74 0a                	je     802785 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  80277b:	a1 80 80 80 00       	mov    0x808080,%eax
  802780:	8b 40 78             	mov    0x78(%eax),%eax
  802783:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  802785:	a1 80 80 80 00       	mov    0x808080,%eax
  80278a:	8b 40 70             	mov    0x70(%eax),%eax
}
  80278d:	83 c4 10             	add    $0x10,%esp
  802790:	5b                   	pop    %ebx
  802791:	5e                   	pop    %esi
  802792:	5d                   	pop    %ebp
  802793:	c3                   	ret    

00802794 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802794:	55                   	push   %ebp
  802795:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802797:	8b 45 08             	mov    0x8(%ebp),%eax
  80279a:	89 c2                	mov    %eax,%edx
  80279c:	c1 ea 16             	shr    $0x16,%edx
  80279f:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8027a6:	f6 c2 01             	test   $0x1,%dl
  8027a9:	74 26                	je     8027d1 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  8027ab:	c1 e8 0c             	shr    $0xc,%eax
  8027ae:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  8027b5:	a8 01                	test   $0x1,%al
  8027b7:	74 18                	je     8027d1 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  8027b9:	c1 e8 0c             	shr    $0xc,%eax
  8027bc:	8d 14 40             	lea    (%eax,%eax,2),%edx
  8027bf:	c1 e2 02             	shl    $0x2,%edx
  8027c2:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  8027c7:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  8027cc:	0f b7 c0             	movzwl %ax,%eax
  8027cf:	eb 05                	jmp    8027d6 <pageref+0x42>
  8027d1:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8027d6:	5d                   	pop    %ebp
  8027d7:	c3                   	ret    
	...

008027e0 <__udivdi3>:
  8027e0:	55                   	push   %ebp
  8027e1:	89 e5                	mov    %esp,%ebp
  8027e3:	57                   	push   %edi
  8027e4:	56                   	push   %esi
  8027e5:	83 ec 10             	sub    $0x10,%esp
  8027e8:	8b 45 14             	mov    0x14(%ebp),%eax
  8027eb:	8b 55 08             	mov    0x8(%ebp),%edx
  8027ee:	8b 75 10             	mov    0x10(%ebp),%esi
  8027f1:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8027f4:	85 c0                	test   %eax,%eax
  8027f6:	89 55 f0             	mov    %edx,-0x10(%ebp)
  8027f9:	75 35                	jne    802830 <__udivdi3+0x50>
  8027fb:	39 fe                	cmp    %edi,%esi
  8027fd:	77 61                	ja     802860 <__udivdi3+0x80>
  8027ff:	85 f6                	test   %esi,%esi
  802801:	75 0b                	jne    80280e <__udivdi3+0x2e>
  802803:	b8 01 00 00 00       	mov    $0x1,%eax
  802808:	31 d2                	xor    %edx,%edx
  80280a:	f7 f6                	div    %esi
  80280c:	89 c6                	mov    %eax,%esi
  80280e:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802811:	31 d2                	xor    %edx,%edx
  802813:	89 f8                	mov    %edi,%eax
  802815:	f7 f6                	div    %esi
  802817:	89 c7                	mov    %eax,%edi
  802819:	89 c8                	mov    %ecx,%eax
  80281b:	f7 f6                	div    %esi
  80281d:	89 c1                	mov    %eax,%ecx
  80281f:	89 fa                	mov    %edi,%edx
  802821:	89 c8                	mov    %ecx,%eax
  802823:	83 c4 10             	add    $0x10,%esp
  802826:	5e                   	pop    %esi
  802827:	5f                   	pop    %edi
  802828:	5d                   	pop    %ebp
  802829:	c3                   	ret    
  80282a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802830:	39 f8                	cmp    %edi,%eax
  802832:	77 1c                	ja     802850 <__udivdi3+0x70>
  802834:	0f bd d0             	bsr    %eax,%edx
  802837:	83 f2 1f             	xor    $0x1f,%edx
  80283a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  80283d:	75 39                	jne    802878 <__udivdi3+0x98>
  80283f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802842:	0f 86 a0 00 00 00    	jbe    8028e8 <__udivdi3+0x108>
  802848:	39 f8                	cmp    %edi,%eax
  80284a:	0f 82 98 00 00 00    	jb     8028e8 <__udivdi3+0x108>
  802850:	31 ff                	xor    %edi,%edi
  802852:	31 c9                	xor    %ecx,%ecx
  802854:	89 c8                	mov    %ecx,%eax
  802856:	89 fa                	mov    %edi,%edx
  802858:	83 c4 10             	add    $0x10,%esp
  80285b:	5e                   	pop    %esi
  80285c:	5f                   	pop    %edi
  80285d:	5d                   	pop    %ebp
  80285e:	c3                   	ret    
  80285f:	90                   	nop
  802860:	89 d1                	mov    %edx,%ecx
  802862:	89 fa                	mov    %edi,%edx
  802864:	89 c8                	mov    %ecx,%eax
  802866:	31 ff                	xor    %edi,%edi
  802868:	f7 f6                	div    %esi
  80286a:	89 c1                	mov    %eax,%ecx
  80286c:	89 fa                	mov    %edi,%edx
  80286e:	89 c8                	mov    %ecx,%eax
  802870:	83 c4 10             	add    $0x10,%esp
  802873:	5e                   	pop    %esi
  802874:	5f                   	pop    %edi
  802875:	5d                   	pop    %ebp
  802876:	c3                   	ret    
  802877:	90                   	nop
  802878:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  80287c:	89 f2                	mov    %esi,%edx
  80287e:	d3 e0                	shl    %cl,%eax
  802880:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802883:	b8 20 00 00 00       	mov    $0x20,%eax
  802888:	2b 45 f4             	sub    -0xc(%ebp),%eax
  80288b:	89 c1                	mov    %eax,%ecx
  80288d:	d3 ea                	shr    %cl,%edx
  80288f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802893:	0b 55 ec             	or     -0x14(%ebp),%edx
  802896:	d3 e6                	shl    %cl,%esi
  802898:	89 c1                	mov    %eax,%ecx
  80289a:	89 75 e8             	mov    %esi,-0x18(%ebp)
  80289d:	89 fe                	mov    %edi,%esi
  80289f:	d3 ee                	shr    %cl,%esi
  8028a1:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8028a5:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8028a8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8028ab:	d3 e7                	shl    %cl,%edi
  8028ad:	89 c1                	mov    %eax,%ecx
  8028af:	d3 ea                	shr    %cl,%edx
  8028b1:	09 d7                	or     %edx,%edi
  8028b3:	89 f2                	mov    %esi,%edx
  8028b5:	89 f8                	mov    %edi,%eax
  8028b7:	f7 75 ec             	divl   -0x14(%ebp)
  8028ba:	89 d6                	mov    %edx,%esi
  8028bc:	89 c7                	mov    %eax,%edi
  8028be:	f7 65 e8             	mull   -0x18(%ebp)
  8028c1:	39 d6                	cmp    %edx,%esi
  8028c3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8028c6:	72 30                	jb     8028f8 <__udivdi3+0x118>
  8028c8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8028cb:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  8028cf:	d3 e2                	shl    %cl,%edx
  8028d1:	39 c2                	cmp    %eax,%edx
  8028d3:	73 05                	jae    8028da <__udivdi3+0xfa>
  8028d5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  8028d8:	74 1e                	je     8028f8 <__udivdi3+0x118>
  8028da:	89 f9                	mov    %edi,%ecx
  8028dc:	31 ff                	xor    %edi,%edi
  8028de:	e9 71 ff ff ff       	jmp    802854 <__udivdi3+0x74>
  8028e3:	90                   	nop
  8028e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8028e8:	31 ff                	xor    %edi,%edi
  8028ea:	b9 01 00 00 00       	mov    $0x1,%ecx
  8028ef:	e9 60 ff ff ff       	jmp    802854 <__udivdi3+0x74>
  8028f4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8028f8:	8d 4f ff             	lea    -0x1(%edi),%ecx
  8028fb:	31 ff                	xor    %edi,%edi
  8028fd:	89 c8                	mov    %ecx,%eax
  8028ff:	89 fa                	mov    %edi,%edx
  802901:	83 c4 10             	add    $0x10,%esp
  802904:	5e                   	pop    %esi
  802905:	5f                   	pop    %edi
  802906:	5d                   	pop    %ebp
  802907:	c3                   	ret    
	...

00802910 <__umoddi3>:
  802910:	55                   	push   %ebp
  802911:	89 e5                	mov    %esp,%ebp
  802913:	57                   	push   %edi
  802914:	56                   	push   %esi
  802915:	83 ec 20             	sub    $0x20,%esp
  802918:	8b 55 14             	mov    0x14(%ebp),%edx
  80291b:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80291e:	8b 7d 10             	mov    0x10(%ebp),%edi
  802921:	8b 75 0c             	mov    0xc(%ebp),%esi
  802924:	85 d2                	test   %edx,%edx
  802926:	89 c8                	mov    %ecx,%eax
  802928:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  80292b:	75 13                	jne    802940 <__umoddi3+0x30>
  80292d:	39 f7                	cmp    %esi,%edi
  80292f:	76 3f                	jbe    802970 <__umoddi3+0x60>
  802931:	89 f2                	mov    %esi,%edx
  802933:	f7 f7                	div    %edi
  802935:	89 d0                	mov    %edx,%eax
  802937:	31 d2                	xor    %edx,%edx
  802939:	83 c4 20             	add    $0x20,%esp
  80293c:	5e                   	pop    %esi
  80293d:	5f                   	pop    %edi
  80293e:	5d                   	pop    %ebp
  80293f:	c3                   	ret    
  802940:	39 f2                	cmp    %esi,%edx
  802942:	77 4c                	ja     802990 <__umoddi3+0x80>
  802944:	0f bd ca             	bsr    %edx,%ecx
  802947:	83 f1 1f             	xor    $0x1f,%ecx
  80294a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  80294d:	75 51                	jne    8029a0 <__umoddi3+0x90>
  80294f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802952:	0f 87 e0 00 00 00    	ja     802a38 <__umoddi3+0x128>
  802958:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80295b:	29 f8                	sub    %edi,%eax
  80295d:	19 d6                	sbb    %edx,%esi
  80295f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802962:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802965:	89 f2                	mov    %esi,%edx
  802967:	83 c4 20             	add    $0x20,%esp
  80296a:	5e                   	pop    %esi
  80296b:	5f                   	pop    %edi
  80296c:	5d                   	pop    %ebp
  80296d:	c3                   	ret    
  80296e:	66 90                	xchg   %ax,%ax
  802970:	85 ff                	test   %edi,%edi
  802972:	75 0b                	jne    80297f <__umoddi3+0x6f>
  802974:	b8 01 00 00 00       	mov    $0x1,%eax
  802979:	31 d2                	xor    %edx,%edx
  80297b:	f7 f7                	div    %edi
  80297d:	89 c7                	mov    %eax,%edi
  80297f:	89 f0                	mov    %esi,%eax
  802981:	31 d2                	xor    %edx,%edx
  802983:	f7 f7                	div    %edi
  802985:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802988:	f7 f7                	div    %edi
  80298a:	eb a9                	jmp    802935 <__umoddi3+0x25>
  80298c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802990:	89 c8                	mov    %ecx,%eax
  802992:	89 f2                	mov    %esi,%edx
  802994:	83 c4 20             	add    $0x20,%esp
  802997:	5e                   	pop    %esi
  802998:	5f                   	pop    %edi
  802999:	5d                   	pop    %ebp
  80299a:	c3                   	ret    
  80299b:	90                   	nop
  80299c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8029a0:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8029a4:	d3 e2                	shl    %cl,%edx
  8029a6:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8029a9:	ba 20 00 00 00       	mov    $0x20,%edx
  8029ae:	2b 55 f0             	sub    -0x10(%ebp),%edx
  8029b1:	89 55 ec             	mov    %edx,-0x14(%ebp)
  8029b4:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8029b8:	89 fa                	mov    %edi,%edx
  8029ba:	d3 ea                	shr    %cl,%edx
  8029bc:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8029c0:	0b 55 f4             	or     -0xc(%ebp),%edx
  8029c3:	d3 e7                	shl    %cl,%edi
  8029c5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8029c9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  8029cc:	89 f2                	mov    %esi,%edx
  8029ce:	89 7d e8             	mov    %edi,-0x18(%ebp)
  8029d1:	89 c7                	mov    %eax,%edi
  8029d3:	d3 ea                	shr    %cl,%edx
  8029d5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8029d9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  8029dc:	89 c2                	mov    %eax,%edx
  8029de:	d3 e6                	shl    %cl,%esi
  8029e0:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  8029e4:	d3 ea                	shr    %cl,%edx
  8029e6:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  8029ea:	09 d6                	or     %edx,%esi
  8029ec:	89 f0                	mov    %esi,%eax
  8029ee:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  8029f1:	d3 e7                	shl    %cl,%edi
  8029f3:	89 f2                	mov    %esi,%edx
  8029f5:	f7 75 f4             	divl   -0xc(%ebp)
  8029f8:	89 d6                	mov    %edx,%esi
  8029fa:	f7 65 e8             	mull   -0x18(%ebp)
  8029fd:	39 d6                	cmp    %edx,%esi
  8029ff:	72 2b                	jb     802a2c <__umoddi3+0x11c>
  802a01:	39 c7                	cmp    %eax,%edi
  802a03:	72 23                	jb     802a28 <__umoddi3+0x118>
  802a05:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a09:	29 c7                	sub    %eax,%edi
  802a0b:	19 d6                	sbb    %edx,%esi
  802a0d:	89 f0                	mov    %esi,%eax
  802a0f:	89 f2                	mov    %esi,%edx
  802a11:	d3 ef                	shr    %cl,%edi
  802a13:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802a17:	d3 e0                	shl    %cl,%eax
  802a19:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802a1d:	09 f8                	or     %edi,%eax
  802a1f:	d3 ea                	shr    %cl,%edx
  802a21:	83 c4 20             	add    $0x20,%esp
  802a24:	5e                   	pop    %esi
  802a25:	5f                   	pop    %edi
  802a26:	5d                   	pop    %ebp
  802a27:	c3                   	ret    
  802a28:	39 d6                	cmp    %edx,%esi
  802a2a:	75 d9                	jne    802a05 <__umoddi3+0xf5>
  802a2c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802a2f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802a32:	eb d1                	jmp    802a05 <__umoddi3+0xf5>
  802a34:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802a38:	39 f2                	cmp    %esi,%edx
  802a3a:	0f 82 18 ff ff ff    	jb     802958 <__umoddi3+0x48>
  802a40:	e9 1d ff ff ff       	jmp    802962 <__umoddi3+0x52>
